Unsubscribe links in notification emails

UPDATE: Unsubscribe links have been implemented as a feature and are available now in version 10.7 of Subscribe2 HTML.


TL;DR – I’m thinking of adding a feature allowing unsubscription links in the notification email in the next version. I hope I’ve found a good implementation for this feature as it isn’t straightforward. What do you think? Comments please… 😉


For a long time the Roadmap for Subscribe2 has stated that unsubscribe links in the notification emails has been considered and dismissed as a development route.

Why? Well, for a few reasons:

  • Subscribe2 is designed to be able to send individual emails but it can also be configured to send a single email to multiple recipients via the email BCC header – so the unsubscribe link would not be individual to each recipient
  • Subscribe2 can send up to 4 email types and in 2 formats, HTML and plain text – formatting can get messy when trying to implement a solution for all email types
  • Subscribe2 supports two user type, Registered and Public – the latter can click on a link to delete their email address but Registered Subscribers need to log in to their profile and change their setting – so a single link isn’t enough

So, where are we at right now?

Well, I think I have a satisfactory and workable solution now that I can spend more time developing Subscribe2 HTML while Subscribe2 is looked after by the folks at ReadyGraph. (See here for more about that split).

Basically, I have implemented a new {KEYWORD} called {UNSUBLINK}. This keyword is replaced by an unsubscribe link for Public Subscribers and a link to the ‘Your Subscriptions’ admin page for Registered Subscribers. These links are very basic in their implementation to allow for the plain text emails.

So, to allow greater control over the final output in the email there are also API filters for both links that passes both the generated link and the email type. This allows individual sites to use a little code to add some text and formatting to the link depending on the link and the email type. So for example (see below) you can return a nice sentence to Registered Subscribers with a word linked to the ‘Your Subscriptions’ page.

function custom_public_unsublink( $link, $email_type ) {
	if ( 'text' === $email_type ) {
		return "To unsubscribe click here:\r\n" . $link;
	} else {
		return 'To unsubscribe click here:
<a href="' . $link . '">' . $link . '</a>';
	}
}
add_filter( 's2_unsublink_public', 'custom_public_unsublink', 10, 2 );

function custom_registered_unsublink( $link, $email_type ) {
	if ( 'text' === $email_type ) {
		return "You may manage your subscription options from your profile\r\n" . $link;
	} else {
		return sprintf( 'You may manage your subscription options from your <a href="%s">profile</a>', $link );
	}
}
add_filter( 's2_unsublink_registered', 'custom_registered_unsublink', 10, 2 );

Finally then, this is the best solution I can currently think of, but I’m happy to hear some feedback on this before I push this feature out. Comments are open so let’s have some constructive feedback please. [Off topic comments will be deleted!]

Advertisements