Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save someguy9/b24866f521ec3eb20b13feb4c72a6afd to your computer and use it in GitHub Desktop.

Select an option

Save someguy9/b24866f521ec3eb20b13feb4c72a6afd to your computer and use it in GitHub Desktop.

Revisions

  1. someguy9 revised this gist May 14, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion disable-wordpress-admin-new-user-notification.php
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ function smartwp_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
    //Only send the new user their email, not the admin
    $notify = 'user';
    }
    wp_send_new_user_notifications( $user_id, $notify );
  2. someguy9 created this gist May 14, 2020.
    21 changes: 21 additions & 0 deletions disable-wordpress-admin-new-user-notification.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    <?php
    //Disable the new user notification sent to the site admin
    function smartwp_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', 'smartwp_send_new_user_notifications' );
    add_action( 'edit_user_created_user', 'smartwp_send_new_user_notifications', 10, 2 );
    }
    function smartwp_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 );
    }
    add_action( 'init', 'smartwp_disable_new_user_notifications' );