Post Notification Filters
Post Notifications have a few filters that will allow you to modify the base functionality of the feature. This article will go over each filter in detail.
sendpress-post-notifications-list
This filter allows you to change the list that post notifications gets sent to. By default post notifications get sent to the post notifications list, and subscribers are selected by the looking at the users selected post notifications schedule. Using the filter, you can tell post notifications the list ID you'd like to send to, and you can programmatically choose your list based on the schedule type.
Example:
// Our filter callback function function example_callback( $default_list_id, $type ) { $new_list_id = 12345; return $new_list_id; } add_filter( 'sendpress-post-notifications-list', 'example_callback', 10, 3 );
sendpress-post-notifications-confirm-send
This filter allows you to look at the the schedule type being sent and the post or posts being sent and choose to continue sending the current notification.
// Our filter callback function function example_callback( $type, $posts ) { //do some things return true; //false if you don't want to send } add_filter( 'sendpress-post-notifications-confirm-send', 'example_callback', 10, 3 );
sendpress-post-notifications-content
This filter allows you to modify the array of posts that are about to be sent. The array structure needs to stay the same in order for post notifications to work successfully, but you can add anything to the array via this filter.
// Our filter callback function function example_callback( $posts ) { //do some things return $posts; } add_filter( 'sendpress-post-notifications-content', 'example_callback', 10, 3 );
sendpress-post-notifications-override-content
This filter will allow you to override all the content being sent in the current notification. This includes any content added or changed in the previous filter! Simply return any HTML you'd like to send.
// Our filter callback function function example_callback( $posts ) { return 'Hello World!'; } add_filter( 'sendpress-post-notifications-override-content', 'example_callback', 10, 3 );