Subscription Form

Updated


Form Shortcode

Content Notify comes with a shortcode that can be added anywhere to show the ‘Create Subscription’ form.

content notify subscription form
An un-styled form shown in the (non-Bootstrap) Twenty Twenty WordPress theme.

 

content notify subscription form styled
A fully-styled form shown in a Bootstrap-based WordPress theme.

 

To add the form in the new Block Editor (Gutenberg) or using the Classic Editor, simply use the shortcode: [cn_form]

You can customise the output of the form by adding some parameters to the shortcode:

  • Use 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 page/post/custom post type, select it, and hide the Notify When field.
  • Use 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 parameter will hide the Are field.
  • Use taxonomies="" with a comma separated list of taxonomies that you want to limit the output of the In field.
  • Use 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 page, select it, and hide the By field.

For example, you have Posts, Pages, 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: [cn_form post_types="movies,events"]

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 form, including any shortcode parameters, to a theme template file, you can use this code:
<?php echo apply_shortcodes( '[cn_form]' ); ?>


Form Errors

On submission, and once the page has been reloaded, the page that features the shortcode will show any validation errors above the form or will hide the form and display a success message when it is correctly submitted.

It is not recommended to put the form into a modal popup as the page needs to refresh in order to submit and validate the entered data.


Privacy Policy Link

The Privacy Policy link is automatically added from the page set in Settings > Privacy in the WordPress Admin.


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 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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
.cn-form {}
.cn-error {}
.cn-success {}
.cn-form {}
.cn-required-asterisk {}
.cn-email-address {}
.cn-names {}
.cn-first-name {}
.cn-last-name {}
.cn-when-are-by {}
.cn-when {}
.cn-are {}
.cn-by
.cn-taxonomies {}
.cn-taxonomy-row {}
.cn-taxonomy {}
.cn-privacy {}
.cn-submit {}

Styling Alerts

Alerts are shown when a form passes or fails validation, or a subscriber attempts to verify/delete their subscription. The CSS classes available are:

1
2
3
.cn-success {}
.cn-warning {}
.cn-error {}