Subscribe to Category

Description

This plugin lets a user subscribe and unsubscribe to posts within a certain category or categories (email conformation is required when a subscription is added while not logged in).
Subscribers will receive an e-mail notification with a link to the actual post. E-mails to subscribers are sent once every hour (adjustable) with WP Cron.

The HTML form is prepared for Bootstrap framework.

Subscribers are saved as a custom post type with a possibillity to export and import(excel/csv). Un/Subscription needs to be confirmed by the subscriber.

The following settings and features are available for the administrator in current version:

  • Change e-mail sender from default
  • Change the title/subject for e-mails
  • Number is characters from the content include in the email notification
  • List of available Custom Taxonomies (Checkbox 0, 1 or more items)
  • Enable operation of shortcode attribute “hide_unsubscribe”
  • Set the reschedule time for the cron job
  • Option for re-send a post on update that has already been sent.
  • Choose between classic/gutenberg editor output
  • Turn CSS on/off
  • Export subscribers to a tab delimited CSV file with a possibility to filter by categories
  • Import subscribers from a tab delimited CSV file (with the same format as created by the export function) with a possibility to filter the categories
  • Run the cron job manually so it will fire immediately
  • Theres a note when next scheduled event for sending e-mails to subscribers is running.
  • Options for leave no trace – deletes post meta and subscribers created by this plugin.
  • Implementation by widget and / or short code.

Screenshots

  • Settings page.
  • With Bootstrap framework.
  • Without Bootstrap framework, override and add your own css.
  • When resend post is enabled in settings there is a new option available when editing a post.
  • When resend post and Gutenberg editor settings are both enabled, Resend options are available in the Gutenberg document tab
  • Taxonomy edit possibility
  • STC Subscibers list with one custom taxonomy called "Taxonomies"

Installation

This section describes how to install the plugin and get it working.

  1. Upload subscribe-to-category to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress Admin
  3. Save your settings ‘Settings > Subscribe’.
  4. Create a page and add shortcode [stc-subscribe] or use the STC Widget to display stc form subscription.

Shortcode Attributes

‘category_in’ – Use this attribute if you only want one or several categories to be available for subscription. Value to be entered is the name of the category.
‘category_id_in’ – The difference to above is to use the category ID instead of category name.

‘category_not_in’ – Use this attribute if you want to exclude categories to be available for subscription. Value to be entered is the name of the category.
‘category_id_not_in’ – The difference to above is to use the category ID instead of category name.

‘hide_unsubscribe’ – Disables the unsubscribe feature is the shortcode attribuet is enabled at the admin setting

For the above attributes you can use a comma sign to separate multiple categories, like [stc-subscribe category_in=”news, article”].

Filter and hooks

Following filters and hooks can be used for customizing the email message.

<?php
// FILTERS
// Parameters: $value
add_filter( 'stc_message_length_sum_of_words', 'stc_message_length_sum_of_words', 10, 1 ); //set return value to a negative number to show the full content


// Parameters: $value, $post_id, $subscriber_post_id
add_filter( 'stc_message_title_html', 'my_stc_message_title_html', 10, 3 );
add_filter( 'stc_message_link_to_post_html', 'my_stc_message_link_to_post_html', 10, 3 );
add_filter( 'stc_message_unsubscribe_html', 'my_stc_message_unsubscribe_html', 10, 3 );
add_filter( 'stc_message_subscribe_html', 'my_stc_message_subscribe_html', 10, 3 );

// HOOKS
// Parameters: $post_id, $subscriber_post_id  
add_action( 'stc_before_message', 'my_stc_before_message', 10, 2 );
add_action( 'stc_before_message_title', 'my_stc_before_message_title', 10, 2 );
add_action( 'stc_after_message_title', 'my_stc_after_message_title', 10, 2 );
add_action( 'stc_before_message_content', 'my_stc_before_message_content', 10, 2 );
add_action( 'stc_after_message_content', 'my_stc_after_message_content', 10, 2 );
add_action( 'stc_after_message', 'my_stc_after_message', 10, 2 );

// Parameters: $subscriber_post_id, $categories, bool $all_categories
add_action( 'stc_after_update_subscriber', 'my_stc_after_update_subscriber', 10, 3 );
add_action( 'stc_after_insert_subscriber', 'my_stc_after_insert_subscriber', 10, 3 );

// Parameters: $subscriber_post_id, 
add_action( 'stc_before_unsubscribe', 'my_stc_before_unsubscribe', 10, 1 ); // runs before deleting a subscriber from database
add_action( 'stc_before_subscribe', 'my_stc_before_subscribe', 10, 1 ); // runs before adding a subscriber to the database


/**
 * Example for adding featured image to STC email
 */
function my_stc_after_message_title( $post_id ){
    echo get_the_post_thumbnail( $post_id, 'thumbnail' );
}
add_action( 'stc_after_message_title', 'my_stc_after_message_title', 10, 2 );

?>

Optionally but recommended

As WordPress Cron is depending on that you have visits on your website you should set up a cron job on your server to hit http://yourdomain.com/wp-cron.php at a regular interval to make sure that WP Cron is running as expected. In current version of Subscribe to Category the WP Cron is running once every hour, that might be an option that is changeable in future versions.
Therefore a suggested interval for your server cron could be once every 5 minutes.

FAQ

Can STC handle custom Taxonomies

Yes from verison 2.3.1 it is possble to link STC with custom created Taxonomies. You can activate these within STC on the admin setting page.

Reviews

སྤྱི་ཟླ་དྲུག་པ། 5, 2020
This plugin does exactly what I need, it lets my users subscribe to a category and then receive an email every time a post is added to that category. Users can add themselves to multiple categories and catogories can be excluded from the opt in. Excellent
སྤྱི་ཟླ་གཉིས་པ། 22, 2020
How can do the same for custom post type.... this for normal posts... please answer
སྤྱི་ཟླ་གཉིས་པ། 10, 2017
Uses shortcodes to let your users subscribe to category posts. I like that the developer made it possible to exclude or include categories from the list. I have posts that are just for updating the slider and was able to exclude those from the subscription list. Thanks!
Read all 17 reviews

Contributors & Developers

“Subscribe to Category” is open source software. The following people have contributed to this plugin.

Contributors

“Subscribe to Category” has been translated into 2 locales. Thank you to the translators for their contributions.

Translate “Subscribe to Category” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

2.3.1

  • New admin setting to select custom taxonomies names (shortcode for taxonomy selection comes later for now use admin edit of subscription)
  • Muliple post to one discriber are added together in one notification.
  • bugfixes

2.2.1

  • Introduced subscriber verification for subscriptions and updates while not logged in to WordPress
  • Introduced disabling of the unsubscribe checkbox
  • New admin setting to control the length of the content in the email notification
  • bugfixes

2.1.7

  • Added email conformation to intended stc subscriber. When confirmed the new stc subscriber becomes active. This is not required when the user is in admin mode.

2.1.6

  • minor bugfixes

2.1.5

  • changed subscription method for existing subscribers to enable updating the subscription
  • bug fixed with only one category causing nothing to show

2.1.4

  • Changed tekst for using the Gutenberg/Block editor to be more clear
  • Redirect to first page after subscription stays now on the current page
  • Bug fixed causing not to update the subscribers when using the classic WP editor

2.1.3

  • Added an admin feature to import a csv subscriberlist in exactly the same format as created by the export function

2.1.2

  • Added an admin setting to control the WP-Cron STC rescheduling “send email time”. Default is 3600 second but the user can now set it to any value between 180 and 3600 => 2 minutes and 1 hour

2.1.1

  • during sanitizing process the email adress from the unsubscriber lost the “@” sign causing failed unsubscribtion issues

2.1.0

  • implemented sanitizing and escaping according WPCS
  • adapted internationalization text domain to plugin standards
  • added ‘numberposts’ => -1 to the args for exporting all subscribers to excel it was defaulting to a maximum of 5
  • minor buxfixes

2.0.0

  • adapted stc to wp 5.3 features by adding a stc resend option to the document tab

1.9.0

  • Email address preset for logged in users.
  • Japanese, Dutch, German and Norwegian language added.

1.8.1

  • Added pot file to be used for translation.
  • Bugfix – changed textdomain to string instead of constant.

1.7.0

  • Added some new hooks: stc_after_update_subscriber, stc_after_insert_subscriber, stc_before_unsubscribe.

1.6.0

  • Added a Widget for subscription form.
  • Don’t show category list if only one is available (thanks to davefx).
  • Extended short code attributes with an option to use category id instead of category name (thanks to Stingray_454).

1.3

  • Added hooks and filters to make the plugin extensible.
  • Added Lithuanian language.

1.2.1

  • Fixed some undefined variables that might have caused some errors for some environments.
  • Renamed language files for russian language to correct syntax.
  • Added Italian language.

1.2.0

  • Possibillity to re-send a post on update that has already been sent. This option needs to be activated in the settings for the plugin.
  • Attribute ‘category_in’ added to shortcode to show only entered categories in the subscribe form. Multiple categories are separated by a comma sign.
  • Attribute ‘category_not_in’ added to shortcode to exclude categories in the subscribe form. Multiple categories are separated by a comma sign.

1.1.0

  • Added php sleep() function to prevent sending all e-mails in the same scope.
  • Using Ajax when send is manually triggered in back-end.

1.0.0

  • First release