Blog

Using WP shortcodes in your form

Posted by:

You are here:
← All Topics

Within any formula you can also get the value from a shortcode, you can use this formula to fill a field (like a text box or hidden field) or you could use it to do other operations for example, you could use a shortcode to get the status of a user and then use that info to calculate a price or to hide a field.

To use shortcodes in your formulas do the following

1.- Open the formula editor in the setting that you want to fill, in the example below I want to use a formula to fill a field so I will use the “Default text” setting (for more info about how to create formulas check this tutorial):

2.- Click on “Add Field”

3.- Click on “ShortCode”

4.- Configure the shortcode. In this step, you can define the name, content, and attributes of the shortcode. You can also see a preview of how the shortcode looks like.

5.- Click apply

6.- That’s it! now your formula has a shortcode in it.

If all you want to do is fill a field with the content of a shortcode this formula is enough but you might want to do something more complex. For example, let’s say that your shortcode returns a product price and you would like to multiply it by a quantity field. If so you could use a formula like this:

The formula above would retrieve the value of the shortcode and will multiply it by the quantity field.

Editing a Shortcode formula

To edit a shortcode all you have to do is double-click on it.

Creating interactive forms with shortcodes

You can also use values from other fields to form your shortcode, for example in the shortcode below I am using the value of the field “Product Id” to create my shortcode. All I need to do is click on the tag icon to add a field within a shortcode attribute or content.

When you add a field with a shortcode every time this field changes the shortcode will be refreshed as well.

0

About the Author:

Im programmer working for an international company. I have programmed since i was 12 and i have done it professionally for 6 years. Programming for a company is fun and i have learned a lot of things but i have always been interested in running my own business so i decided to give it a shot doing what i do best, programming stuffs.
  Related Posts
  • No related posts found.