Content Notify comes with a shortcode that can be added anywhere to show the ‘Create Subscription’ form.
You can only use the shortcode from the plugin to add a Subscription form and cannot use another plugin to create a subscription form for Content Notify, e.g. Gravity Forms.
To add the Content Notify form in the new Block Editor (Gutenberg) or using the Classic Editor, simply use the shortcode:
You can also add the Content Notify form as either a Classic Widget, or a Block Widget. If using a block widget, it is recommended to use the ‘Shortcode’ block widget type.
Here is the full shortcode, in it’s default form:
[cn_form user_fields="true" user_names="true" post_types="" post_id="" status="" authors="" taxonomies="" logic="OR" search="true" privacy_policy="true" captcha="false" submit_label="Create Subscription"]
You can customise the output of the Content Notify form by adding some parameters to the shortcode:
user_fields="false"when a user is logged in and you don’t want to show the auto-populated Email Address, First Name, and Last Name fields in your form. If the user is logged out, these fields will show, even if this parameter is added to the shortcode.
user_names="false"if you don’t want the First Name or Last Name fields to show in the form.
post_types=""with a comma separated list of post types that you want to limit the output of the Notify When field. Setting this to ‘auto’ or ‘false’ will detect the post type of the current post/page/custom post type, select it, and hide the Notify When field. Setting this to a single post type will hide the Notify When field but will show it when more than one post type is specified.
post_id=""with the post ID (e.g. 2314) to limit subscriptions to updates for a specific post/page/custom post type. Setting this to ‘auto’ will detect the post ID for the post/page/custom post type that the form is embedded on and use that instead. Setting either option will hide the ‘post type’ and ‘status’ fields in the Content Notify form as only post/page/custom post type that have already been published can utilise this.
status=""with a single or comma separated list of post statuses that you want to limit the output of the Are field. Only ‘publish’ and ‘update’ statuses are available at this time. Setting this field to ‘false’ will set the field to alert of both statuses. I.e. if a post is published OR updated. Setting this parameter will hide the the Are field.
authors=""with a comma separated list of authors that you want to limit the output of the By field. Setting this to ‘false’ will hide the By field. Setting this to ‘auto’ will detect the author of the current post/page/custom post type, select it, and hide the By field.
taxonomies=""with a comma separated list of taxonomies that you want to limit the output of the In field. Setting this to ‘false’ will hide the In field.
logic=""to set the form to using and logic or or logic. Settings this to and will ensure an alert is only triggered when all taxonomies chosen have at least one matching term. Setting this to or will ensure an alert will be triggered when *any* taxonomy and any terms chosen are matched. When this shortcode parameter is excluded, the form’s logic defaults to or.
search="true"to enable the keyword search field. This will allow users to trigger an alert based on search for a keyword in the title or content of a post/page/custom post type. Users can add multiple keywords by comma separating them, and use a plus sign ‘+’ to join words and search for them as phrases. Setting this to ‘false’ will hide the Keyword Search field.
captcha="true"to show a CAPTCHA field at the bottom of your Content Notify form. This then needs to be configured in Subscriptions > Settings > Security in the WordPress Admin. More detail on this can be found here.
submit_label=""to change the text on the ‘Submit’ button. If not set, this will default to ‘Create Subscription’.
For example, you have Posts, Pages, Media, Movies, and Events as post types on your site but you only want users to be able to create subscriptions for Movies and Events. Just use this shortcode:
Similarly, if you want to limit this further by only allowing users to create subscriptions for the Actors (custom taxonomy for Movies) and Local (custom taxonomy for Events), then use this shortcode:
[cn_form post_types="movies,events" taxonomies="actors,local"]
The order of post types and taxonomies doesn’t matter – Content Notify will understand and work out which taxonomies are associated with which post types. Magic!
Adding to Template Files
Should you wish to add the Content Notify form, including any shortcode parameters, to a theme template file, you can use this code:
<?php echo apply_shortcodes( '[cn_form]' ); ?>
On submission, and once the page has been reloaded, the page that features the shortcode will show any validation errors above the Content Notify form or will hide the form and display a success message when it is correctly submitted.
It is not recommended to put the Content Notify form into a modal popup as the page needs to refresh in order to submit and validate the entered data.
Logged In Users
Users that are logged in will benefit from their first name, last name, and email address being pre-populated in the form, providing that this information is available in their user account.
Styling the Form
The Content Notify form uses standard Bootstrap classes so that it will integrate with the many, many themes that use Bootstrap as their underlying CSS framework.
The form also uses unique Content Notify classes so that you can style it further should you wish. The CSS classes available are:
Alerts are shown when a Content Notify form passes or fails validation, or a subscriber attempts to verify/delete their subscription. The CSS classes available are: