Filters in Jetpack to customize subscription delivery

wordpress

Filters in Jetpack to customize subscription delivery.

Three filters have been made available since version 3.7 that allows you to customize which posts get emailed to your subscribers. To do so, you would need to add the code to a functionality plugin or directly to your theme’s functions.php file.

1. jetpack_allow_per_post_subscriptions: Option to toggle email delivery on a per-post basis.

  • Filter: jetpack_allow_per_post_subscriptions
  • Will add a checkbox option to every new post of whether or not to email the post to subscribers.
  • Example usage: wp-contentpluginsjetpackmodulessubscriptions.php

 

php
add_filter( 'jetpack_allow_per_post_subscriptions', 'true' );

After change:

Using filters in Jetpack to customize subscription delivery

 

2. jetpack_subscriptions_exclude_these_categories: Exclude certain categories from ever emailing to subscribers.

  • Filter: jetpack_subscriptions_exclude_these_categories
  • Will never send subscriptions emails to whatever categories are in that array
  • Example usage: wp-contentpluginsjetpackmodulessubscriptions.php

 

php
add_filter( 'jetpack_subscriptions_exclude_these_categories', 'exclude_these' );
function exclude_these( $categories ) {
    $categories = array( 'category-slug', 'category-slug-2');
    return $categories;
}

 

3. jetpack_subscriptions_exclude_all_categories_except: Exclude all posts from emailing to subscribers, except ones in these categories.

  • Filter: jetpack_subscriptions_exclude_all_categories_except
  • Will never send subscription email for posts, UNLESS the post in in one of these categories.
  • Example usage: wp-contentpluginsjetpackmodulessubscriptions.php
php
add_filter( 'jetpack_subscriptions_exclude_all_categories_except', 'exclude_all_except' );
function exclude_all_except( $categories ) {
    $categories = array( 'category-slug', 'category-slug-2');
    return $categories;
}

 

A note about these filters:

  • These filters are not meant to be used together. Only one should be used at a time. They will override each other and it will be awkward.
  • If either of the category filters are set, then the per-post checkbox will not display no matter what.

 

Thanks for watching!