WordPress 5.2 integrated WSoD protection which by default it will send an email notification to admin when the site encounters some fatal error. I had built my client a site which I would like to monitor such error in case it happens, but I dont want to insert an admin role in my client site just for this purpose. Is there any hook which I can also set an additional technical support email if such events occur?
Asked
Active
Viewed 1,330 times
1 Answers
3
You are looking for the recovery mode hooks. The first way, the simpler one, is setting the RECOVERY_MODE_EMAIL
constant inside your wp-config.php.
define( 'RECOVERY_MODE_EMAIL', 'you@example.com' );
It’s also possible to change the Recovery Mode email address through the recovery_mode_email
filter:
add_filter( 'recovery_mode_email', function( $email ) {
$email['to'] = 'you@example.com';
return $email;
} );
This way you will get the mail instead of your client, client is not scared and you are informed of the issue. If you want this sent to multiple addresses, return the emails as an array:
add_filter( 'recovery_mode_email', function( $email ) {
$email['to'] = array('you1@example.com', 'you2@example.com');
return $email;
} );
It is recommended to place your filter implementation into a separate plugin or mu-plugin to avoid Fatal Errors in theme that would cause the filter to never fire.

GeorgeP
- 784
- 10
- 26
-
@GeorageP, thanks for your details explaination. Wondering if the filter 'recovery_mode_email' will work in mu-plugin? – HW Siew Dec 11 '20 at 01:36
-
Yes, and that is the recommended way of using it instead of say `functions.php`. See: https://core.trac.wordpress.org/ticket/47939 – GeorgeP Dec 11 '20 at 01:37
-
1hey @GeorageP, wondering if you know how can i test the recovery mail? I tried to make a syntax error in one plugin but the recovery mail is not sent for both admin and my additional email. I have tested my host email service is working. d – HW Siew Dec 12 '20 at 04:15
-
do i need to enable the recovery mode manually? – HW Siew Dec 12 '20 at 04:15