Solved

Wordpress Query

Posted on 2016-10-09
1
33 Views
Last Modified: 2016-11-07
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

0
Comment
Question by:rgranlund
1 Comment
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 41836348
Have you based your javascript code on the example in the documentation for wp_send_json? https://codex.wordpress.org/Function_Reference/wp_send_json
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now