network_admin_email_change_email is a WordPress PHP filter that allows you to modify the content of the email notification sent when the network admin email address is changed.
Usage
function my_network_admin_email_change_email( $email_change_email, $old_email, $new_email, $network_id ) { return $email_change_email; } add_filter( 'network_admin_email_change_email', 'my_network_admin_email_change_email', 10, 4 );
Parameters
$email_change_email
(array): An array containing email information used to build thewp_mail()
function.$old_email
(string): The old network admin email address.$new_email
(string): The new network admin email address.$network_id
(int): The ID of the network.
Examples
Change email subject
function change_network_email_subject( $email_change_email, $old_email, $new_email, $network_id ) { $email_change_email['subject'] = 'Important: Network admin email address update'; return $email_change_email; } add_filter( 'network_admin_email_change_email', 'change_network_email_subject', 10, 4 );
This code snippet customizes the email subject line to “Important: Network admin email address update”.
Add a custom footer to the email message
function add_email_footer( $email_change_email, $old_email, $new_email, $network_id ) { $email_change_email['message'] .= "\n\n--\nYour custom footer text here."; return $email_change_email; } add_filter( 'network_admin_email_change_email', 'add_email_footer', 10, 4 );
This code snippet adds a custom footer to the email message.
Change email recipient
function change_email_recipient( $email_change_email, $old_email, $new_email, $network_id ) { $email_change_email['to'] = '[email protected]'; return $email_change_email; } add_filter( 'network_admin_email_change_email', 'change_email_recipient', 10, 4 );
This code snippet changes the email recipient to ‘[email protected]‘.
Add BCC to email headers
function add_bcc_header( $email_change_email, $old_email, $new_email, $network_id ) { $email_change_email['headers'][] = 'BCC: [email protected]'; return $email_change_email; } add_filter( 'network_admin_email_change_email', 'add_bcc_header', 10, 4 );
This code snippet adds a BCC recipient to the email headers.
Customize email message with additional details
function customize_email_message( $email_change_email, $old_email, $new_email, $network_id ) { $email_change_email['message'] = str_replace( '###OLD_EMAIL###', 'Old email: ' . $old_email . "\nNew email: " . $new_email, $email_change_email['message'] ); return $email_change_email; } add_filter( 'network_admin_email_change_email', 'customize_email_message', 10, 4 );
This code snippet customizes the email message, replacing the ###OLD_EMAIL###
placeholder with a custom string containing both the old and new email addresses.