To add the user’s email address in the REST API response, register an additional field to the user object and add the email address:
register_rest_field(
'user',
'user_email',
[
'get_callback' => static function (array $user): string {
return get_userdata($user['id'])->user_email;
},
]
);
Please note, however, that this is strongly discouraged because anyone can then see the email addresses if the code is running on a publicly accessible website.
Related Posts:
- Get UserInfo from WordPress
- get_user_meta() doesn’t include user email?
- Confirmation required on email change
- Email user when password is reset by admin
- How to set up User email verification after Signup?
- Retrieve all users from wordpress database via REST/JSON API
- Basic auth WordPress REST API dilemma
- Send activation email to user after signup [duplicate]
- get_userdata by username
- Buddypress – Send New User Activation Link to Admin [closed]
- Send Email to Users after Deleting Account
- Adding second Email address for WP user notifications
- Add email addresses to already registered users
- How can I check if a user’s email exists in the database
- Suddenly all emails in User have [email protected]
- Rest API code to get ID of current user not working: get_current_user_id() gives 0
- Translate emails into the language of the user
- WordPress API for search
- Is there a way to identify a user in a custom REST API method? [duplicate]
- How can I authenticate user credentials against a WordPress instance?
- Rest api return all users (even without content) to all users
- How to notify specific users when i’m posting/modifying a new post
- Unable to change email address of admin on localhost
- No user found when using REST API
- WordPress REST Api: update user
- REST API: wp_get_current_user not working on second call
- Send email to all registered users [closed]
- how to remove email field from default user registration form on wordpress
- What is correct way to change user’s email?
- Send clear password via mail
- Need to manually add multiple WP users with same e-mail address (with good reason)
- WP Create User – Preventing repeated information
- User with same Mail but a different additional info(like domain)
- User can’t search himself on rest api
- How to verify which WordPress user requested the API in ASP .NET Core?
- Need to use WordPress page as authentication for different service
- How do I update user email from frontend input field?
- Custom Password Reset
- Is there a way to call via javascript if a user is logged-in on a static html file?
- Send user auto generated password on different email
- change user password REST API
- how to retrieve user via rest api using custom meta and/or email
- Getting user data via ajax
- How can I display Only the first Array/Object?
- How to customize user rest api?
- The same session information for peer users on two different WordPress servers
- REST API list_user
- How to update a user with REST API v2 knowing only the username?
- REST_query_vars for users
- User email verification without a plugin, is it possible?
- Exclude Current user email and send notification
- New User Registration email
- how can i inform other users about new user registration? [closed]
- Why does a super admin on multi site get a rest_user_invalid_id error code when requesting user details through REST?
- Email Subscribe for Downloads in WordPress
- Recognize logged WP user in existing REST API
- Can’t retrieve user email address with REST API
- Editor can create any new user except administrator
- get_current_user_id() returns 0?
- REST API endpoint for elasticpress autosuggest
- How to assign capabilities to user NOT to User Role
- Setting WP Admin passwords to expire
- Getting users who registered 360 days from current date
- Querying Email Addresses for a List of Users with Same Last Name?
- Can’t send emails through REST API
- Changing default Buddypress avatar affects all site avatars (because gravatar)
- 14,000 WordPress Users. How did they get there?
- how to make a profile entry read only except for site managers [closed]
- Managing Users and Creating Groups [closed]
- Upgrade Nightmare – No Posts, Permissions Issues and Can’t Create a new post
- Max no of simultaneous active sessions for a single user
- Fix permissions for users role
- Redirect subscribers to last viewed page after log-in
- User Meta Data in a Sortable Table
- Are there mutiple ways to get usernames (as a hacker)
- search users using user name and user meta in wordpress
- Custom Comment Notifications Fire on each Page Load
- The Simple and Correct Way to Add User Meta
- Export Users and their Advanced Custom Fields
- Hide hour from displaying when using user_registered
- How to copy user_nicename value into user_login
- Custom route and query
- Check if user is logged in via JS? [duplicate]
- Easiest way to create an user across several websites
- How to change default username field after login
- Post Taxonomy Value get from User Field Value
- Iterating users while user iteration is suppressed
- How to require files in a custom endpoint
- In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?
- user and usermeta table not found
- UserMeta Changes Meta Value for Post ID
- Users set passwords but cannot login
- Subscriber role – blank page
- Set user role on registration so can upload file to own media library area
- User “none” role
- show count author post today
- Limit user access to installing/configuring a plugin?
- Increase by one the user counter on specific role
- Website for online video conferences with students and teachers with WordPress?
- Unable to retrieve Users (Not logged in) through WP Rest API