Created
August 3, 2015 21:38
-
-
Save LinzardMac/e9260af209e43141f695 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUsers(){ | |
header("Access-Control-Allow-Origin: *"); | |
$term = $_GET['search']; | |
// var_dump($_GET); | |
$args = array( | |
'search' => '*'.esc_attr( $term ).'*', | |
'fields' => array('first_name', 'last_name', 'ID', 'display_name'), | |
'meta_query' => array( | |
'relation' => 'OR', | |
array( | |
'key' => 'first_name', | |
'value' => $term, | |
'compare' => 'LIKE' | |
), | |
array( | |
'key' => 'last_name', | |
'value' => $term, | |
'compare' => 'LIKE' | |
) | |
) | |
); | |
// The Query | |
$user_query = new WP_User_Query( $args ); | |
$results = array(); | |
// here you can see the whole user object being returned | |
wp_die(var_dump($user_query->results)); | |
$results['results'] = $user_query->get_results(); | |
$response = json_encode($results); | |
echo($response); | |
die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment