Global fields / elements
Need the same field or element on existing forms? The global field method might be helpful in these scenario's. To add a field to all your existing forms by altering the form via WordPress hooks.
Let's assume you already created 50 forms, but you now require a hidden field that holds the current page URL.
At the time of writing Super Forms doesn't yet come with a feature that allows you to add a so called Global field
.
However you can easily achieve this with a small function like the one below.
The code will alter the current form elements array and add a new hidden field named page_url
with the default value set to {post_permalink}
which retrieves the current page URL.
Of course you can add multiple fields by altering the JSON code below. If you are not sure how to format them, you could create a temporary form in the back-end, add your fields and then view the [CODE]
tab on the builder page to copy the JSON value.
If you only require this to be fired for specific forms, you can add a condition based on the $form_id
parameter value.
Place the below code at the bottom of your child theme functions.php
Last updated