Skip to:
Content

BuddyPress.org

Changeset 12349


Ignore:
Timestamp:
03/01/2019 02:33:56 AM (8 years ago)
Author:
boonebgorges
Message:

Use display name as salutation in signup emails.

Previously, the user login was used, because the display name was not
yet saved in the database. However, we can generally extract the user's
provided display name from the signup's meta fields.

Fixes #8056.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-filters.php

    r12284 r12349  
    470470                ),
    471471        );
    472         bp_send_email( 'core-user-registration-with-blog', array( array( $user_email => $user ) ), $args );
     472
     473        $signups = BP_Signup::get(
     474                array(
     475                        'user_login' => $user,
     476                )
     477        );
     478
     479        $salutation = $user;
     480        if ( $signups ) {
     481                $signup = $signups['signups'][0];
     482                if ( isset( $signup->meta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) {
     483                        $salutation = $signup->meta[ 'field_' . bp_xprofile_fullname_field_id() ];
     484                }
     485        }
     486
     487        bp_send_email( 'core-user-registration-with-blog', array( array( $user_email => $salutation ) ), $args );
    473488
    474489        // Return false to stop the original WPMU function from continuing.
    … …  
    522537        if ( $user_object ) {
    523538                $user_id = $user_object->ID;
     539        }
     540
     541        $salutation = $user;
     542        if ( isset( $meta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) {
     543                $salutation = $meta[ 'field_' . bp_xprofile_fullname_field_id() ];
     544        } elseif ( $user_id ) {
     545                $salutation = bp_core_get_user_displayname( $user_id );
    524546        }
    525547
    … …  
    532554                ),
    533555        );
    534         bp_send_email( 'core-user-registration', array( array( $user_email => $user ) ), $args );
     556        bp_send_email( 'core-user-registration', array( array( $user_email => $salutation ) ), $args );
    535557
    536558        // Return false to stop the original WPMU function from continuing.
  • trunk/src/bp-members/bp-members-functions.php

    r11829 r12349  
    17421742                 */
    17431743                if ( apply_filters( 'bp_core_signup_send_activation_key', true, $user_id, $user_email, $activation_key, $usermeta ) ) {
    1744                         bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key, $user_login );
     1744                        $salutation = $user_login;
     1745                        if ( isset( $usermeta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) {
     1746                                $salutation = $usermeta[ 'field_' . bp_xprofile_fullname_field_id() ];
     1747                        }
     1748
     1749                        bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key, $salutation );
    17451750                }
    17461751        }
    … …  
    21592164 * @since 1.2.2
    21602165 * @since 2.5.0 Add the $user_login parameter.
     2166 * @since 5.0.0 Change $user_login parameter to more general $salutation.
    21612167 *
    21622168 * @param int|bool $user_id    ID of the new user, false if BP_SIGNUPS_SKIP_USER_CREATION is true.
    2163  * @param string   $user_email Email address of the new user.
    2164  * @param string   $key        Activation key.
    2165  * @param string   $user_login Optional. The user login name.
    2166  */
    2167 function bp_core_signup_send_validation_email( $user_id, $user_email, $key, $user_login = '' ) {
     2169 * @param string   $user_email   Email address of the new user.
     2170 * @param string   $key          Activation key.
     2171 * @param string   $salutation   Optional. The name to be used as a salutation in the email.
     2172 */
     2173function bp_core_signup_send_validation_email( $user_id, $user_email, $key, $salutation = '' ) {
    21682174        $args = array(
    21692175                'tokens' => array(
    … …  
    21752181        );
    21762182
    2177         if ( $user_id ) {
    2178                 $to = $user_id;
    2179         } else {
    2180                 $to = array( array( $user_email => $user_login ) );
    2181         }
     2183        $to = array( array( $user_email => $salutation ) );
    21822184
    21832185        bp_send_email( 'core-user-registration', $to, $args );
  • trunk/src/bp-members/classes/class-bp-signup.php

    r11804 r12349  
    640640                                // Send the validation email.
    641641                                } else {
    642                                         bp_core_signup_send_validation_email( false, $signup->user_email, $signup->activation_key, $signup->user_login );
     642                                        $salutation = $signup->user_login;
     643                                        if ( isset( $meta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) {
     644                                                $salutation = $meta[ 'field_' . bp_xprofile_fullname_field_id() ];
     645                                        }
     646
     647                                        bp_core_signup_send_validation_email( false, $signup->user_email, $signup->activation_key, $salutation );
    643648                                }
    644649                        }
Note: See TracChangeset for help on using the changeset viewer.