Solved

Wordpress Query

Posted on 2016-10-09
1
43 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

734 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