Make WordPress Core

Changeset 49029


Ignore:
Timestamp:
09/21/2020 05:14:33 PM (6 years ago)
Author:
johnbillion
Message:

Users: Introduce the invited_user_email filter for filtering the contents of the email sent when an existing user is invited to a site on Multisite.

Props contact-banker, anand.au14, nikolam, johnbillion

Fixes #42132

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/user-new.php

    r48042 r49029  
    6060
    6161        // Adding an existing user to this blog.
    62         $new_user_email = $user_details->user_email;
     62        $new_user_email = array();
    6363        $redirect       = 'user-new.php';
    6464        $username       = $user_details->user_login;
     
    101101
    102102                        /**
    103                          * Fires immediately after a user is invited to join a site, but before the notification is sent.
     103                         * Fires immediately after an existing user is invited to join the site, but before the notification is sent.
    104104                         *
    105105                         * @since 4.4.0
     
    124124                        );
    125125
     126                        $new_user_email['to']      = $user_details->user_email;
     127                        $new_user_email['subject'] = sprintf(
     128                                /* translators: Joining confirmation notification email subject. %s: Site title. */
     129                                __( '[%s] Joining Confirmation' ),
     130                                wp_specialchars_decode( get_option( 'blogname' ) )
     131                        );
     132                        $new_user_email['message'] = sprintf(
     133                                $message,
     134                                get_option( 'blogname' ),
     135                                home_url(),
     136                                wp_specialchars_decode( translate_user_role( $role['name'] ) ),
     137                                home_url( "/newbloguser/$newuser_key/" )
     138                        );
     139                        $new_user_email['headers'] = '';
     140
     141                        /**
     142                         * Filters the contents of the email sent when an existing user is invited to join the site.
     143                         *
     144                         * @since 5.6.0
     145                         *
     146                         * @param array $new_user_email {
     147                         *     Used to build wp_mail().
     148                         *
     149                         *     @type string $to      The email address of the invited user.
     150                         *     @type string $subject The subject of the email.
     151                         *     @type string $message The content of the email.
     152                         *     @type string $headers Headers.
     153                         * }
     154                         * @param int    $user_id     The invited user's ID.
     155                         * @param array  $role        Array containing role information for the invited user.
     156                         * @param string $newuser_key The key of the invitation.
     157                         *
     158                         */
     159                        $new_user_email = apply_filters( 'invited_user_email', $new_user_email, $user_id, $role, $newuser_key );
     160
    126161                        wp_mail(
    127                                 $new_user_email,
    128                                 sprintf(
    129                                         /* translators: Joining confirmation notification email subject. %s: Site title. */
    130                                         __( '[%s] Joining Confirmation' ),
    131                                         wp_specialchars_decode( get_option( 'blogname' ) )
    132                                 ),
    133                                 sprintf(
    134                                         $message,
    135                                         get_option( 'blogname' ),
    136                                         home_url(),
    137                                         wp_specialchars_decode( translate_user_role( $role['name'] ) ),
    138                                         home_url( "/newbloguser/$newuser_key/" )
    139                                 )
     162                                $new_user_email['to'],
     163                                $new_user_email['subject'],
     164                                $new_user_email['message'],
     165                                $new_user_email['headers']
    140166                        );
    141167
Note: See TracChangeset for help on using the changeset viewer.