Hooks & Filters

Updated

Content Notify contains a number of useful filters so that you can customise various aspects of the plugin. These are:


Filter: Alert Subject – Publish

cn\alert\subject\publish

Purpose: Filter for the subject field when a publish status is used on any post type.

Example:
function cn_filter_subject_publish( $subject ) {
$subject = __( 'Alert: New ' . $post_type_name[0]['single'] . ' Published', 'cn' );
return $subject;
}
add_filter( 'cn\alert\subject\publish', 'cn_filter_subject_publish' );


Filter: Alert Subject – Update

cn\alert\subject\update

Purpose: Filter for the subject field when an update status is used on any post type.

Example:
function cn_filter_subject_update( $subject ) {
$subject = __( 'Alert: ' . $post_type_name[0]['single'] . ' Updated', 'cn' );
return $subject;
}
add_filter( 'cn\alert\subject\update', 'cn_filter_subject_update' );


Filter: Email HTML

cn\alert\html

Purpose: Filter the HTML that Content Notify sends in an email.
Note: You can also customise the HTML email using a template file. Details of this can be found here.

Example:
function cn_filter_html( $email_html, $subject, $featured, $title, $message, $links, $sender_details ) {
$email_html = 'INSERT CONTENTS OF THE wp-content/plugins/content-notify/templates/alert-email.php FILE HERE';
return $email_html;
}
add_filter( 'cn\alert\html', 'cn_filter_html' );


Filter: User Alert Message

cn\alert\user\message

Purpose: Filter for the message field used on any post type.

Example:
function cn_filter_user_message( $message ) {
if ( empty( $post->post_password ) ) {
$message = $post->post_content;
}
return $message;
}
add_filter( 'cn\alert\user\message', 'cn_filter_user_message' );


Filter: Admin Alert Message

cn\alert\admin\message

Purpose: Filter for the message in the alert that is sent to the admin when a user verifies their subscription.

Example:
function cn_filter_admin_message( $message ) {
$message = "
<p>" . __( "Here's what they signed up for: ", 'cn' ) . "</p>
" . $message_name . "
" . $mesage_post_type . "
" . $message_status . "
" . $message_author . "
" . $message_terms . "
" . $message_keywords . "
<p class='btn-container'><a href='" . get_edit_post_link( $subscription['ID'], false ) . "' class='btn btn-primary'>" . __( 'View Subscription', 'cn' ) . "</a></p>
";
return $message;
}
add_filter( 'cn\alert\admin\message', 'cn_filter_admin_message' );

Get started

Start using it today

Ready to transform your communications for your
visitors, members, subscribers, and users?

View Pricing
14-DAY MONEY BACK GUARANTEE
ON NEW PURCHASES