Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/27/2016 09:15:07 PM (10 years ago)
Author:
djpaul
Message:

Emails: refactor notification functions and use bp_send_email to send email.

Backwards compatibility is mostly maintained, though there are a few unavoidable instances where some data passed to filters is no longer sent (an empty string or equivalent is provided to avoid PHP Notices). These will be detailed in a post on bpdevel.wordpress.com in the feature to alert plugin developers.

See #6592. Props timersys, mercime, boonebgorges, hnla, DJPaul.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-settings/bp-settings-actions.php

    r10417 r10479  
    101101
    102102                    bp_update_user_meta( bp_displayed_user_id(), 'pending_email_change', $pending_email );
    103 
    104                     $email_text = sprintf(
    105                         __( 'Dear %1$s,
    106 
    107 You recently changed the email address associated with your account on %2$s.
    108 If this is correct, please click on the following link to complete the change:
    109 %3$s
    110 
    111 You can safely ignore and delete this email if you do not want to take this action or if you have received this email in error.
    112 
    113 This email has been sent to %4$s.
    114 
    115 Regards,
    116 %5$s
    117 %6$s', 'buddypress' ),
    118                         bp_core_get_user_displayname( bp_displayed_user_id() ),
    119                         bp_get_site_name(),
    120                         esc_url( bp_displayed_user_domain() . bp_get_settings_slug() . '/?verify_email_change=' . $hash ),
    121                         $user_email,
    122                         bp_get_site_name(),
    123                         bp_get_root_domain()
     103                    $verify_link = bp_displayed_user_domain() . bp_get_settings_slug() . '/?verify_email_change=' . $hash;
     104
     105                    // Send the verification email
     106                    $args = array(
     107                        'tokens' => array(
     108                            'displayname'    => bp_core_get_user_displayname( bp_displayed_user_id() ),
     109                            'old-user.email' => $old_user_email,
     110                            'user.email'     => $user_email,
     111                            'verify.url'     => esc_url( $verify_link ),
     112                        ),
    124113                    );
    125 
    126                     /**
    127                      * Filter the email text sent when a user changes emails.
    128                      *
    129                      * @since 2.1.0
    130                      *
    131                      * @param string  $email_text     Text of the email.
    132                      * @param string  $new_user_email New user email that the
    133                      *                                current user has changed to.
    134                      * @param string  $old_user_email Existing email address
    135                      *                                for the current user.
    136                      * @param WP_User $update_user    Userdata object for the current user.
    137                      */
    138                     $content = apply_filters( 'bp_new_user_email_content', $email_text, $user_email, $old_user_email, $update_user );
    139 
    140                     // Send the verification email
    141                     wp_mail( $user_email, sprintf( __( '[%s] Verify your new email address', 'buddypress' ), wp_specialchars_decode( bp_get_site_name() ) ), $content );
     114                    bp_send_email( 'settings-verify-email-change', bp_displayed_user_id(), $args );
    142115
    143116                    // We mark that the change has taken place so as to ensure a
Note: See TracChangeset for help on using the changeset viewer.