Make WordPress Core

Ticket #11210: 11210_pluggable.php.adds-hooks.patch

File 11210_pluggable.php.adds-hooks.patch, 2.6 KB (added by nacin, 15 years ago)

Quick attempt to add hooks to wp_new_user_notification

  • pluggable.php

     
    11381138if ( !function_exists('wp_new_user_notification') ) :
    11391139/**
    11401140 * Notify the blog admin of a new user, normally via email.
     1141 * Also sends email to new user with plaintext password.
    11411142 *
    11421143 * @since 2.0
     1144 * @uses apply_filters() Calls 'wp_new_user_notification_admin' hook on an array of all of admin mail parameters.
     1145 * @uses apply_filters() Calls 'wp_new_user_notification_user' hook on an array of all of user mail parameters.
    11431146 *
    11441147 * @param int $user_id User ID
    11451148 * @param string $plaintext_pass Optional. The user's plaintext password
     1149 *
    11461150 */
    11471151function wp_new_user_notification($user_id, $plaintext_pass = '') {
    11481152        $user = new WP_User($user_id);
    11491153
    1150         $user_login = stripslashes($user->user_login);
    1151         $user_email = stripslashes($user->user_email);
     1154        $user_login = stripslashes( $user->user_login );
     1155        $user_email = stripslashes( $user->user_email );
    11521156
    1153         $message  = sprintf(__('New user registration on your blog %s:'), get_option('blogname')) . "\r\n\r\n";
    1154         $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    1155         $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
     1157        $message  = sprintf( __('New user registration on your blog %s:'), get_option( 'blogname' ) ) . "\r\n\r\n";
     1158        $message .= sprintf( __('Username: %s'), $user_login ) . "\r\n\r\n";
     1159        $message .= sprintf( __('E-mail: %s'), $user_email ) . "\r\n";
    11561160
    1157         @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message);
     1161        $subject = sprintf(__('[%s] New User Registration'), get_option('blogname') );
     1162        $to = get_option( 'admin_email' );
    11581163
    1159         if ( empty($plaintext_pass) )
     1164        $send = true;
     1165        extract( apply_filters( 'wp_new_user_notification_admin', compact( 'send', 'to', 'subject', 'message' ) ) );
     1166
     1167        if ( $send )
     1168                @wp_mail(get_option('admin_email'), $subject, $message);
     1169
     1170        if ( empty( $plaintext_pass) ) )
    11601171                return;
    11611172
    11621173        $message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
    11631174        $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
    11641175        $message .= wp_login_url() . "\r\n";
    11651176
    1166         wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);
     1177        $subject = sprintf( __('[%s] Your username and password'), get_option( 'blogname' ) );
    11671178
     1179        $send = true;
     1180        extract( apply_filters( 'wp_new_user_notification_user', compact( 'send', 'to', 'subject', 'message' ) ) );
     1181
     1182        if ( $send )
     1183                wp_mail($user_email, $subject, $message);
     1184
    11681185}
    11691186endif;
    11701187