Last active
July 21, 2022 06:53
-
-
Save runezero/c872c73cf7d7e3d72ede653ab0c05e48 to your computer and use it in GitHub Desktop.
[Disable update and account mails] Disable all succesfull update mails and user registration emails #wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'auto_core_update_send_email', 'disable_auto_core_updates', 10, 4); | |
| add_filter( 'admin_email_check_interval', '__return_false' ); | |
| add_action( 'init', 'dev_disable_new_user_notifications' ); | |
| //Disable the updated feature notification emails | |
| function disable_auto_core_updates( $send, $type, $core_update, $result ) { | |
| if ( ! empty( $type ) && $type == 'success' ) { | |
| return false; | |
| } | |
| return $send; | |
| } | |
| //Disable the new user notification sent to the site admin | |
| function dev_disable_new_user_notifications() { | |
| //Remove original use created emails | |
| remove_action( 'register_new_user', 'wp_send_new_user_notifications' ); | |
| remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 ); | |
| //Add new function to take over email creation | |
| add_action( 'register_new_user', 'dev_send_new_user_notifications' ); | |
| add_action( 'edit_user_created_user', 'dev_send_new_user_notifications', 10, 2 ); | |
| } | |
| function dev_send_new_user_notifications( $user_id, $notify = 'user' ) { | |
| if ( empty($notify) || $notify == 'admin' ) { | |
| return; | |
| }elseif( $notify == 'both' ){ | |
| //Only send the new user their email, not the admin | |
| $notify = 'user'; | |
| } | |
| wp_send_new_user_notifications( $user_id, $notify ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment