Sometimes, rather than a form, it’s nice to have a single button that allows the creation of a simple subscription. This could be referred to as a ‘Follow’ Button.
Content Notify has this feature, out-of-the-box, providing that the user is logged in. If the user is logged out, they will still be shown a few fields, as mentioned below.
Using the Form Builder (Recommended) #
To set this up using the Form Builder, create a new form and disable all of the fields with the except of the ‘Autodetect Post/Page/CPT ID’ which should be enabled.
You can then choose a label for your button, such as ‘Follow’, in the ‘Submit Label Button’ field.
Save the form, and copy the shortcode that it shown in the ‘Form Shortcode’ metabox on the right under the ‘Save’ metabox, and paste it wherever you want the ‘Follow’ button form to show.
If required, you can allow the user to only have a single subscription to this form by checking the ‘One Subscription Per User’ option on the right of the Form Editor screen. When set, a cookie is set to remember that the subscriber has created, by not verified, a subscription. More details about any cookies that Content Notify creates can be found here.
Additionally, you can show an ‘Unsubscribe’ button in place of the ‘Follow’ button once the subscriber has successfully created and verified a subscription to that post/page/custom post type. This is done by toggling the ‘One Subscription Per User’, and then the new ‘Allow Unsubscribe from Post’ option on the right of the Form Editor screen that appears.
Using a Manual Shortcode #
To do this, you need to set up the Content Notify form shortcode in a specific way. Here’s an example of a working ‘Follow’ button set-up for a logged in user:
[cn_form user_fields="false" user_names="false" post_id="auto" authors="false" taxonomies="false" search="false" privacy_policy="false" captcha="false" submit_label="Follow Post"]
In this shortcode, you’re essentially asking the form to:
- Not show the user fields – i.e. the email address, first name, and last name to logged in users.
- Not show the name fields – i.e. the first name and last name to logged out users.
- Set the post ID to the current post. This also sets the post_type to the post type of the current post and the status to ‘update’.
- Not show the authors field.
- Not show the taxonomies field.
- Not show the keyword search field.
- Not show the privacy policy field to logged in users.
- Not show the CAPTCHA field.
- Change the ‘Create Subscription’ button text to say ‘Follow Post’ instead.
Logged In vs. Logged Out #
Once all set, for a logged in user, this will output a single ‘Follow’ button on the page which will set-up the subscription using the above shortcode parameters.
For a logged out user, it will still show the email address, and privacy policy checkbox fields. This is because:
- We need an email address in order to create a subscription. A logged in user will have an email address stored in WordPress that we can use but a logged out user needs to provide one.
- We need the user to agree to the Privacy Policy to comply with the various privacy laws around the world. It is assumed a logged in user has already agreed to these somewhere upon registration.
Once set-up, this form provides a neat and powerful way of creating simple subscriptions using Content Notify.