How can I get the email adress from the users by using the REST API? I'm authenticating with nonce, and it seems to be working since I can do POST requests and change stuff. Do I have to add something to make it return all the user info?

This is my JS:

(function($) {

    var nonce       = WPsettings.nonce;
    var rest_url    = WPsettings.rest_url;

    $.ajax( {
        url: rest_url + 'users/',
        dataType: "json",
        beforeSend: function ( xhr ) {
            xhr.setRequestHeader( 'X-WP-Nonce', nonce );
    } )
   .done( function ( response ) {
        console.log( response );
    } );


you should adding email field in your output.

Use the below hook in your functions.php in your current theme:

register_rest_field( 'user', 'user_email',
        'get_callback'    => function ( $user ) {
            return $user['email'];
        'update_callback' => null,
        'schema'          => null,

But, it not recommended! because everyone can see emails.

  • Thanks, i will try it out! It's not a problem I think since this will be used on a intranet only accessible from a restricted IP adress. – Johan Dahl Sep 2 '17 at 10:31
  • Okay. So you can use this method to get email address from Rest API. Please don't forget to choose best answer :) – Mostafa Soufi Sep 2 '17 at 11:08
  • Great, I will accept your answer as soon as I have confirmed that it works! :) – Johan Dahl Sep 2 '17 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.