Skip to main content
added 16 characters in body
Source Link
Domain
  • 3.3k
  • 1
  • 17
  • 19

Try this

    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
    }

If you know form id for example $form_id then use

$sql = "SELECT id from " . $wpdb->prefix . "rg_lead WHERE created_by=" . $user->ID . " AND form_id=" . $form_id;
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
    }

If you know form id for example $form_id then use

$sql = "SELECT id from " . $wpdb->prefix . "rg_lead WHERE created_by=" . $user->ID . " AND form_id=" . $form_id;

Try this

    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
    }

If you know form id for example $form_id then use

$sql = "SELECT id from " . $wpdb->prefix . "rg_lead WHERE created_by=" . $user->ID . " AND form_id=" . $form_id;
Source Link
Domain
  • 3.3k
  • 1
  • 17
  • 19

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
    }

If you know form id for example $form_id then use

$sql = "SELECT id from " . $wpdb->prefix . "rg_lead WHERE created_by=" . $user->ID . " AND form_id=" . $form_id;