Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have the following function in my functions.php. I am trying to disable the admin from receiving emails every time a new user joins the site. However, the admin is still receiving emails. Is there something wrong with the function? And is this part of the WP options by any chance? I couldn't find the option anywhere.

// Disable New User Reg Emails
if ( ! function_exists( 'wp_new_user_notification' ) ) :
    function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {

        /** Return early if no password is set */
        if ( empty( $plaintext_pass ) )
            return;

        $user       = get_userdata( $user_id );
        $user_login = stripslashes( $user->user_login );
        $user_email = stripslashes( $user->user_email );

        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
        // we want to reverse this for the plain text arena of emails.
        $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );

        $message  = sprintf( __( 'Username: %s' ), $user_login) . "\r\n";
        $message .= sprintf( __( 'Password: %s' ), $plaintext_pass) . "\r\n";
        $message .= wp_login_url() . "\r\n";

        wp_mail( $user_email, sprintf( __( '[%s] Your username and password' ), $blogname ), $message );

    }
endif;
share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

You need to implement your function earlier than you are. It seems that the "real" wp_new_user_notification() (from wp-includes/pluggable.php) is getting created before yours is. To test, remove the if ( ! function_exists( 'wp_new_user_notification' ) ) : from your code. You should be getting an error.

You could create a plugin:

//Plugin Name: blahblah
function wp_new_user_notification() {
  // your code
}

Alternatively, just put that code in it's own .php file and drop it in wp-content/mu-plugins directory (create if it doesn't exist). Problem should be solved.

share|improve this answer
add comment

There's a plugin that can handle disabling new user registrations: http://wordpress.org/extend/plugins/disable-new-user-notifications/

share|improve this answer
    
Hi Chip, that's actually the plugin where I got the function from. I just stripped the function because I didn't want to add another plugin. –  Desi Jan 17 '13 at 21:55
    
And you're using it directly in your functions.php for the theme you're using? –  NW Tech Jan 17 '13 at 22:08
    
Yes, that is correct. –  Desi Jan 17 '13 at 22:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.