Avatar of Robert Granlund
Robert Granlund
Flag for United States of America asked on

Wordpress Query

I am writing an AJAX call with Wordpress.  I have a simple query and for some reason it is not working.   The result of the following query is "access_registration" and I have written it that way so it always passes.  However, it the Console (Chrome) the JSON I get back is:
Object
Am I running the query correctly?


function checkPassword(){
    global $wpdb;

$return = "";
$return = $_POST['regpass'];

$result = $wpdb->get_results( "SELECT user_login FROM wp_dd6xmx2by0_users WHERE ID = '8'");
if($result == 'access_registration') {
    $return = "GO";
} else {
    $return = 'NO GO';
}
wp_send_json($result);
   
}
add_action('wp_ajax_checkPassword', 'checkPassword');
add_action('wp_ajax_nopriv_checkPassword', 'checkPassword');

Open in new window

WordPressPHPAJAX

Avatar of undefined
Last Comment
Terry Woods

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Terry Woods

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck