Make WordPress Core

Ticket #11210: 11210.diff

File 11210.diff, 2.4 KB (added by Denis-de-Bernardy, 11 years ago)

introduce two hooks similar to the one suggested in #25762 - 25762.11.diff

  • wp-includes/pluggable.php

    diff --git wp-includes/pluggable.php wp-includes/pluggable.php
    index 794565f..5891846 100644
    function wp_new_user_notification($user_id, $plaintext_pass = '') { 
    12871287        // we want to reverse this for the plain text arena of emails.
    12881288        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    12891289
     1290        $subject = sprintf(__('[%s] New User Registration', $blogname));
     1291        $email = get_option('admin_email');
     1292
    12901293        $message  = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
    12911294        $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
    12921295        $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
    12931296
    1294         @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
     1297        /**
     1298         * Fires before sending a new user notification by email to that blog's admin.
     1299         *
     1300         * To override the email, or cancel it altogether, apply your custom logic
     1301         * and return false.
     1302         *
     1303         * @since 3.9.0
     1304         *
     1305         * @param boolean $send return false to prevent WP from sending an email
     1306         * @param int $user_id User ID
     1307         * @param string $plaintext_pass Optional. The user's plaintext password
     1308         */
     1309        if (apply_filters('wp_new_user_notification_admin', true, $user_id, $plaintext_pass)) {
     1310                WP_DEBUG ? wp_mail($email, $subject, $message) : @wp_mail($email, $subject, $message);
     1311        }
    12951312
    12961313        if ( empty($plaintext_pass) )
    12971314                return;
    12981315
     1316        $subject = sprintf(__('[%s] Your username and password'), $blogname);
     1317        $email = $user->user_email;
     1318
    12991319        $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
    13001320        $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
    13011321        $message .= wp_login_url() . "\r\n";
    13021322
    1303         wp_mail($user->user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
    1304 
     1323        /**
     1324         * Fires before sending a new user notification by email to that new user.
     1325         *
     1326         * To override the email, or cancel it altogether, apply your custom logic
     1327         * and return false.
     1328         *
     1329         * @since 3.9.0
     1330         *
     1331         * @param boolean $send return false to prevent WP from sending an email
     1332         * @param int $user_id User ID
     1333         * @param string $plaintext_pass Optional. The user's plaintext password
     1334         */
     1335        if (apply_filters('wp_new_user_notification_user', true, $user_id, $plaintext_pass)) {
     1336                WP_DEBUG ? wp_mail($email, $subject, $message) : @wp_mail($email, $subject, $message);
     1337        }
    13051338}
    13061339endif;
    13071340