Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( !function_exists('wp_new_user_notification') ) :
- /**
- * Notify the blog admin of a new user, normally via email.
- *
- * @since 2.0
- *
- * @param int $user_id User ID
- * @param string $plaintext_pass Optional. The user's plaintext password
- */
- 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 site %s:'), $blogname) . "rnrn";
- $message .= sprintf(__('Username: %s'), $user_login) . "rnrn";
- $message .= sprintf(__('E-mail: %s'), $user_email) . "rn";
- @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
- if ( empty($plaintext_pass) )
- return;
- $message = sprintf(__('Username: %s'), $user_login) . "rn";
- $message .= sprintf(__('Password: %s'), $plaintext_pass) . "rn";
- $message .= wp_login_url() . "rn";
- // wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message)
- }
- endif;
- if ( !function_exists( 'wp_new_user_notification' ) ) :
- function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
- return;
- }
- endif;
- if ( !function_exists( 'wp_new_user_notification' ) ) :
- function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
- $user = get_userdata( $user_id );
- $user_login = stripslashes($user->user_login);
- $user_email = stripslashes($user->user_email);
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
- if ( empty($plaintext_pass) ) {
- return;
- }
- $message = sprintf(__('Username: %s'), $user_login) . "rn";
- $message .= sprintf(__('Password: %s'), $plaintext_pass) . "rn";
- $message .= wp_login_url() . "rn";
- wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
- }
- endif;
- add_action( 'register_post', 'maybe_stop_notifications', 10, 3 );
- function maybe_stop_notifications ( $sanitized_user_login, $user_email, $errors ) {
- if( empty( $errors->get_error_code() )) {
- remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
- }
- }
- if ( !function_exists('wp_new_user_notification') ) {
- function wp_new_user_notification( ) {}
- }
Add Comment
Please, Sign In to add comment