Skip to:
Content

BuddyPress.org

Ticket #8139: 8139.06.companion.patch

File 8139.06.companion.patch, 3.5 KB (added by imath, 3 years ago)
  • src/bp-core/bp-core-filters.php

    diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
    index 1b285555c..85a8978d2 100644
    function bp_email_set_default_headers( $headers, $property, $transform, $email ) 
    10741074                        'user_id'           => $user_id,
    10751075                        'notification_type' => $email->get( 'type' ),
    10761076                );
    1077                 // If this email is not to a current member, include the nonmember's email address.
     1077
     1078                // If this email is not to a current member, include the nonmember's email address and the Inviter ID.
    10781079                if ( ! $user_id ) {
    10791080                        $args['email_address'] = $tokens['recipient.email'];
     1081                        $args['member_id']     = bp_loggedin_user_id();
    10801082                }
    10811083
    10821084                $link = bp_email_get_unsubscribe_link( $args );
  • src/bp-core/bp-core-functions.php

    diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
    index 98b46f5ce..0ad97989d 100644
    function bp_email_get_type_schema( $field = 'description' ) { 
    40274027                'description'   => __( 'A site member has sent a site invitation to the recipient.', 'buddypress' ),
    40284028                'unsubscribe'   => array(
    40294029                        'meta_key'      => 'notification_bp_members_invite',
    4030                         'message'       => __( 'You will no longer receive emails when you are invited to join a site.', 'buddypress' ),
     4030                        'message'       => __( 'You will no longer receive emails when you are invited to join this site.', 'buddypress' ),
    40314031                ),
    40324032        );
    40334033
    function bp_email_unsubscribe_handler() { 
    40714071        $raw_user_id    = ! empty( $_GET['uid'] ) ? absint( $_GET['uid'] ) : 0;
    40724072        $raw_user_email = ! empty( $_GET['uem'] ) ? $_GET['uem'] : '';
    40734073        $raw_member_id  = ! empty( $_GET['mid'] ) ? absint( $_GET['mid'] ) : 0;
     4074        $redirect_to    = '';
    40744075
    40754076        $new_hash = '';
    40764077        if ( ! empty( $raw_user_id ) ) {
    function bp_email_unsubscribe_handler() { 
    41164117                        'email_type'    => $raw_email_type,
    41174118                        'date_modified' => bp_core_current_time(),
    41184119                );
    4119                 $result      = bp_add_optout( $optout_args );
    4120                 $redirect_to = home_url();
    4121                 $result_msg  = $emails[ $raw_email_type ]['unsubscribe']['message'];
    4122                 $unsub_msg   = __( 'You have been unsubscribed.', 'buddypress' );
     4120                $result     = bp_add_optout( $optout_args );
     4121                $result_msg = $emails[ $raw_email_type ]['unsubscribe']['message'];
     4122                $unsub_msg  = __( 'You have been unsubscribed.', 'buddypress' );
    41234123
    41244124        // This is an unsubscribe request from a current member.
    41254125        } else {
    function bp_email_unsubscribe_handler() { 
    41414141                $unsub_msg  = __( 'You can change this or any other email notification preferences in your email settings.', 'buddypress' );
    41424142        }
    41434143
    4144         $message = sprintf(
    4145                 '%1$s <a href="%2$s">%3$s</a>',
    4146                 $result_msg,
    4147                 esc_url( $redirect_to ),
    4148                 esc_html( $unsub_msg )
    4149         );
     4144        if ( $raw_user_id && $redirect_to ) {
     4145                $message = sprintf(
     4146                        '%1$s <a href="%2$s">%3$s</a>',
     4147                        $result_msg,
     4148                        esc_url( $redirect_to ),
     4149                        esc_html( $unsub_msg )
     4150                );
    41504151
    4151         bp_core_add_message( $message );
     4152                // Template notices are only displayed on BP pages.
     4153                bp_core_add_message( $message );
     4154                bp_core_redirect( bp_core_get_user_domain( $raw_user_id ) );
    41524155
    4153         $page_redirect = '';
    4154         if ( $raw_user_id  ) {
    4155                 $page_redirect = bp_core_get_user_domain( $raw_user_id );
     4156                exit;
     4157        } else {
     4158                wp_die(
     4159                        sprintf( '%1$s %2$s', esc_html( $unsub_msg ), esc_html( $result_msg ) ),
     4160                        esc_html( $unsub_msg ),
     4161                        array(
     4162                                'link_url'  => home_url(),
     4163                                'link_text' => __( 'Go to website\'s home page.', 'buddypress' ),
     4164                        )
     4165                );
    41564166        }
    4157 
    4158         bp_core_redirect( $page_redirect );
    4159 
    4160         exit;
    41614167}
    41624168
    41634169/**