试试这个
global $wpdb;
$user = wp_get_current_user();
$sql = "SELECT id from " . $wpdb->prefix . "rg_lead WHERE created_by=" . $user->ID;
$results = $wpdb->get_results($sql);
if (count($results) > 0) {
// An entry is made by the user for any form
}
else{
// Show form
}
如果您知道表单id,例如$form\\u id,则使用
$sql = "SELECT id from " . $wpdb->prefix . "rg_lead WHERE created_by=" . $user->ID . " AND form_id=" . $form_id;