Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/19/2017 08:44:53 PM (10 years ago)
Author:
djpaul
Message:

Emails: add List-Unsubscribe header to emails.

The List-Unsubscribe header is an optional chunk of text that email publishers can include in the header portion of the messages they send. In supported email clients, like some versions of Outlook, Gmail, and Apple Mail, recipients will see an Unsubscribe button they can click if they would like to automatically stop future messages.

Fixes #7390

Props chiragpatel, r-a-y.

File:
1 edited

Legend:

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

    r11032 r11395  
    10061006        $headers['X-BuddyPress-Type'] = $email->get( 'type' );
    10071007
     1008        $tokens = $email->get_tokens();
     1009
     1010        // Add 'List-Unsubscribe' header if applicable.
     1011        if ( ! empty( $tokens['unsubscribe'] ) && $tokens['unsubscribe'] !== site_url( 'wp-login.php' ) ) {
     1012                $user = get_user_by( 'email', $tokens['recipient.email'] );
     1013
     1014                $headers['List-Unsubscribe'] = sprintf(
     1015                        '<%s>',
     1016                        esc_url_raw( bp_email_get_unsubscribe_link( array(
     1017                                'user_id'           => $user->ID,
     1018                                'notification_type' => $email->get( 'type' ),
     1019                        ) ) )
     1020                );
     1021        }
     1022
    10081023        return $headers;
    10091024}
Note: See TracChangeset for help on using the changeset viewer.