The admin_email_confirm WordPress PHP action fires before the admin email confirm form is displayed.
Usage
add_action('admin_email_confirm', 'your_custom_function'); function your_custom_function($errors) { // your custom code here }
Parameters
$errors
(WP_Error): A WP_Error object containing any errors generated by using invalid credentials. Note that the error object may not contain any errors.
More information
See WordPress Developer Resources: admin_email_confirm
Examples
Display a custom error message
Display a custom error message if the email address is not valid.
function display_custom_error_message($errors) { if ($errors->get_error_code()) { echo '<div class="error"><p><strong>Error:</strong> Invalid email address.</p></div>'; } } add_action('admin_email_confirm', 'display_custom_error_message');
Log errors to a file
Log any errors to a file for later analysis.
function log_admin_email_confirm_errors($errors) { if ($errors->get_error_code()) { error_log('Admin Email Confirm Error: ' . print_r($errors, true)); } } add_action('admin_email_confirm', 'log_admin_email_confirm_errors');
Display a custom message before the form
Display a custom message before the admin email confirm form.
function display_custom_message($errors) { echo '<div class="notice"><p>Please confirm your email address below.</p></div>'; } add_action('admin_email_confirm', 'display_custom_message');
Add custom CSS styles
Add custom CSS styles to the admin email confirm form.
function add_custom_css_styles($errors) { echo '<style> .error { background-color: #f2dede; } .notice { background-color: #d9edf7; } </style>'; } add_action('admin_email_confirm', 'add_custom_css_styles');
Add custom JavaScript
Add custom JavaScript to the admin email confirm form.
function add_custom_js($errors) { echo '<script> document.addEventListener("DOMContentLoaded", function() { alert("Please confirm your email address."); }); </script>'; } add_action('admin_email_confirm', 'add_custom_js');