我正在使用联系人表格7和“保存联系人表格7”。我希望登录的用户只看到自己的字段。所以,只有当$reservation->user 等于$current_user->user_login.
顺便说一下,当用户提交联系人表单时,其用户值将自动生成为当前用户名。
[text* user readonly default:user_login]
所以,我的问题只是当我试图从数据库中获取表时。
我正在使用以下代码:
global $wpdb;
$current_user = wp_get_current_user();
$username = $current_user->user_login;
echo \'Username: \' . $username . "\\n";
$reservations = $wpdb->get_results( "SELECT * FROM SaveContactForm7_1 WHERE user= \'***I need the condition here***\' ;" );
//print_r( $reservations );
对于将显示在我的页面中的表,以下是代码:
<?php
echo "<table>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>Nom et Prenom</th>";
echo "<th>Qualite</th>";
echo "<th>Arrivee</th>";
echo "<th>Num Vol</th>";
echo "<th>Heure atterrissage</th>";
echo "<th>Provenance</th>";
echo "<th>Depart</th>";
echo "<th>Num Vol</th>";
echo "<th>Decollage</th>";
echo "<th>Destination</th>";
echo "<th>Hotel</th>";
echo "<th>Type de chambre</th>";
echo "<th>Total a payer</th>";
echo "</tr>";
foreach($reservations as $reservation){
echo "<tr>";
echo "<td>".$reservation->user."</td>";
echo "<td>".$reservation->nom."</td>";
echo "<td>".$reservation->qualite."</td>";
echo "<td>".$reservation->datearrivee."</td>";
echo "<td>".$reservation->num_vol_arrivee."</td>";
echo "<td>".$reservation->heure_atterrissage."</td>";
echo "<td>".$reservation->provenance."</td>";
echo "<td>".$reservation->datedepart."</td>";
echo "<td>".$reservation->num_vol_depart."</td>";
echo "<td>".$reservation->heure_decollage."</td>";
echo "<td>".$reservation->destination."</td>";
echo "<td>".$reservation->choix."</td>";
echo "<td>".$reservation->typech."</td>";
echo "<td>".$reservation->calculated_choix."</td>";
echo "</tr>";
}
echo "</table>";
?>