‘recovery_mode_email’ WordPress PHP filter allows you to customize the contents of the Recovery Mode email sent to users.
Usage
To use this filter, add a custom function to your WordPress theme’s functions.php
file or a plugin file. Then, hook your function to the 'recovery_mode_email'
filter, like this:
add_filter( 'recovery_mode_email', 'my_custom_recovery_email', 10, 2 ); function my_custom_recovery_email( $email ) { $email['to'] = '[email protected]'; return $email; } );
Parameters
$email (array)
:to (string|array)
: Array or comma-separated list of email addresses to send the message.subject (string)
: Email subject.message (string)
: Message contents.headers (string|array)
: Optional. Additional headers.attachments (string|array)
: Optional. Files to attach.
$url (string)
: URL to enter recovery mode.
Examples
Customizing the Email Subject
function custom_recovery_email_subject( $email, $url ) { $email['subject'] = 'Website Recovery Mode - Important!'; return $email; } add_filter( 'recovery_mode_email', 'custom_recovery_email_subject', 10, 2 );
Explanation: This code customizes the recovery mode email subject to “Website Recovery Mode – Important!”.
Adding CC and BCC Email Headers
function add_cc_bcc_recovery_email( $email, $url ) { $email['headers'][] = 'Cc: [email protected]'; $email['headers'][] = 'Bcc: [email protected]'; return $email; } add_filter( 'recovery_mode_email', 'add_cc_bcc_recovery_email', 10, 2 );
Explanation: This code adds CC and BCC email headers to the recovery mode email, sending a copy to the specified email addresses.
Appending Custom Text to the Email Message
function append_custom_text_recovery_email( $email, $url ) { $email['message'] .= "nnPlease contact our support team if you need further assistance."; return $email; } add_filter( 'recovery_mode_email', 'append_custom_text_recovery_email', 10, 2 );
Explanation: This code appends custom text to the email message, providing additional support information to the user.
Sending Recovery Email to Multiple Recipients
function send_recovery_email_to_multiple_recipients( $email, $url ) { $email['to'] = array( '[email protected]', '[email protected]' ); return $email; } add_filter( 'recovery_mode_email', 'send_recovery_email_to_multiple_recipients', 10, 2 );
Explanation: This code modifies the recipients of the recovery mode email, sending it to multiple recipients.
Attaching a File to the Recovery Email
function attach_file_recovery_email( $email, $url ) { $email['attachments'][] = '/path/to/your/file.txt'; return $email; } add_filter( 'recovery_mode_email', 'attach_file_recovery_email', 10, 2 );
Explanation: This code attaches a file to the recovery mode email, providing the user with additional information in the form of an attached file.