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
- Condionally/limited emails from system (cantact-form, registration, passwd reset)With
- If the current user is an administrator or editor
- How to change the default registration email ? (plugin and/or non-plugin)
- Editor can create any new user except administrator
- How do I add a field on the Users profile? For example, country, age etc
- WordPress Rest API custom endpoint optional param
- How do I display logged-in username IF logged-in?
- How to allow an user role to create a new user under a role which lower than his level only?
- Using the Rewrite API to Construct a RESTful URL
- user_login vs. user_nicename
- How to programatically change username (user_login)?
- Change the Author Slug from Username to Nickname
- Remove Ability for Other Users to View Administrator in User List?
- Difference between update_user_meta and update_user_option
- Make display name unique
- Make WooCommerce pages accessible for logged in users only
- Find out if logged in user is not subscriber
- WordPress usermeta scaling for thousands of users
- How to get WordPress Username in Array format
- Display user registration date
- Get multiple roles with get_users
- How to Merge Two Authors Into One?
- Whats the best way to share user data across multiple WordPress websites?
- get_current_user_id() returns 0?
- How to get userid at wp_logout action hook?
- Groups of capabilities: users with multiple roles?
- Is there a way to merge two users?
- User-edit role setting distinct from wp_capabilities? [closed]
- List users by last name in WP_User_Query
- What’s the difference between the capability remove_users and delete_users?
- How to restrict access to uploaded files?
- Automatically delete inactive users after 2 months
- How to change user_login with wp-cli?
- Delete all subscribers from wp_users and wp_usermeta a few thousand at a time
- Replacing the WordPress password validation
- Ban a user and end their session
- Allowing users to edit only their page and nobody else’s
- How can 2 blogs share the same users
- alphabetically order role drop-down selection in dashboard
- WordPress auto login after registration not working
- Change the author slug from nickname to ID
- Execute a function when admin changes the user role
- How to let contributors to create a new revision(draft) editing their published posts