Skip to content

Instantly share code, notes, and snippets.

@nmec
Created June 8, 2012 07:56
Show Gist options
  • Save nmec/2894318 to your computer and use it in GitHub Desktop.
Save nmec/2894318 to your computer and use it in GitHub Desktop.
Change default WordPress new user notifications
<?php
/**
* Prevent new user email notifications
* This prevents new user email notifications being sent to users and administrators by commenting out the wp_mail functions. You could rewrite it to change the default registration email.
* This should be put in a plugin or your themes functions file.
* @link http://wordpress.org/extend/plugins/disable-wp-new-user-notification/
* @author Jono Warren <jonathan_warren@bcl.co.uk>
*/
if ( !function_exists('wp_new_user_notification') ) {
function wp_new_user_notification($user_id, $plaintext_pass = '') {
$user = new WP_User($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(__('New user registration on your blog %s:'), $blogname) . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
// email to blog admin commented out by corey salzano
// wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
if ( empty($plaintext_pass) )
return;
$message = sprintf(__('Username: %s'), $user_login) . "\r\n";
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
$message .= wp_login_url() . "\r\n";
// We don't want this emailed either
// wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment