The new_user_email_admin_notice WordPress PHP function displays an admin notice to remind the user to check their email for a confirmation request after changing their email address.
Usage
To use the new_user_email_admin_notice function, simply call it in your code:
new_user_email_admin_notice();
Parameters
This function has no parameters.
More information
See WordPress Developer Resources: new_user_email_admin_notice
Examples
Display the email confirmation notice on the profile page
In this example, we’ll use the new_user_email_admin_notice function to display the email confirmation notice on the user’s profile page:
// Add the email confirmation notice to the user's profile page
function display_email_confirmation_notice() {
new_user_email_admin_notice();
}
add_action('show_user_profile', 'display_email_confirmation_notice');
Display the email confirmation notice on the dashboard
In this example, we’ll display the email confirmation notice on the admin dashboard:
// Add the email confirmation notice to the admin dashboard
function add_email_confirmation_notice_to_dashboard() {
new_user_email_admin_notice();
}
add_action('admin_notices', 'add_email_confirmation_notice_to_dashboard');
Display the email confirmation notice on a custom admin page
In this example, we’ll display the email confirmation notice on a custom admin page:
// Add the email confirmation notice to the custom admin page
function add_email_confirmation_notice_to_custom_page() {
new_user_email_admin_notice();
}
add_action('my_custom_admin_page', 'add_email_confirmation_notice_to_custom_page');
Display the email confirmation notice only for specific user roles
In this example, we’ll display the email confirmation notice only for users with the ‘editor’ role:
// Show the email confirmation notice only for 'editor' role users
function show_email_confirmation_notice_for_editors() {
$current_user = wp_get_current_user();
if (in_array('editor', $current_user->roles)) {
new_user_email_admin_notice();
}
}
add_action('admin_notices', 'show_email_confirmation_notice_for_editors');
Display the email confirmation notice with custom styling
In this example, we’ll display the email confirmation notice with some custom styling:
// Add custom styling to the email confirmation notice
function custom_style_email_confirmation_notice() {
echo '<div class="notice notice-info is-dismissible" style="background-color: #f1c40f; color: #000; border-left-color: #e67e22;">';
new_user_email_admin_notice();
echo '</div>';
}
add_action('admin_notices', 'custom_style_email_confirmation_notice');