Skip to:
Content

BuddyPress.org


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

Emails: add unsubscribe feature.

Updates the unsubscribe token to link to a new unsubscribe action handler.

All emails from other platforms or popular websites have a unsubscribe link. For previous versions of BuddyPress, our unsubscribe link pointed to that user's notifications page. However, if someone creates an account on a BuddyPress with a fraudulent email address (for example), that email address' owner will not know the account's authentication details, and so have no way to unsubscribe from that "spam" email.

The change implements a new action handler which accepts unsubscription requests from un-authenticated requests. It adds an new option containing a dynamically generated salt which is used to generate the hash on the unsubscribe link.

Fixes #6932

Props tharsheblows, DJPaul

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/bp-friends-notifications.php

    r10587 r10941  
    3232        return;
    3333    }
     34
     35    $unsubscribe_args = array(
     36        'user_id'           => $friend_id,
     37        'notification_type' => 'friends-request',
     38    );
    3439
    3540    $args = array(
     
    4146            'initiator.url'       => esc_url( bp_core_get_user_domain( $initiator_id ) ),
    4247            'initiator.name'      => bp_core_get_user_displayname( $initiator_id ),
     48            'unsubscribe'         => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
    4349        ),
    4450    );
     
    6369        return;
    6470    }
     71
     72    $unsubscribe_args = array(
     73        'user_id'           => $initiator_id,
     74        'notification_type' => 'friends-request-accepted',
     75    );
    6576
    6677    $args = array(
     
    7182            'friendship.id'  => $friendship_id,
    7283            'initiator.id'   => $initiator_id,
     84            'unsubscribe'      => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
    7385        ),
    7486    );
Note: See TracChangeset for help on using the changeset viewer.