How to Use Conditional Shortcodes in WordPress Contact Forms
Using conditional shortcodes for email notifications is a common phenomenon. It helps you create tailored notifications directed to specific users.
Let’s learn how to do it, with the fastest WordPress forms builder – Fluent Forms.
How to use conditional shortcode in Fluent Forms
If you want to show a text on your form confirmation based on user submission, you can use this type of shortcode.
Let’s show you a basic structure.
Example:
The shortcodes depend on three parameters. You need to understand them first to use shortcodes.
Field: The field name where the condition will be applied. For instance, if you want to check the value of a radio field’s selection, put that name inside your code.
Condition: As we’re working with the conditional shortcodes, condition is also a parameter here. There are various types of conditions. They are:
You need to use, is=’Your condition’. With the condition, the shortcode will look like this:
Value: The final parameter of a shortcode is the value. It can be any text or number.
The way values are mentioned in a shortcode, to=’Your value’.
For example:
You can use several shortcodes together. If you want different replies for yes and no inputs, this is how to do it:
Nested shortcodes:
It’s like using one conditional shortcode inside of another. The basic structure is like this:
Suppose, in addition to our earlier logic, the user selected ‘yes’, and if he/she gave us a review greater than 2, we want to show a text to that user.
So after using the field name field=”ratings”, conditions is=”greater_than” and value to=”2″ to our nested conditional shortcode, the final shortcode will be –
Use cases:
Conditional shortcodes are used when you want to add so many conditions in one go.
Nesting of the conditional shortcodes might save you time. This will help you show different messages on your email notifications to your users.
This is Sumit. He’s a physics major who’s trying to understand both the physical as well as the WordPress worlds. Whenever he’s not busy, plays fifa or spends time with his family.
Leave a Reply
You must be logged in to post a comment.