getting-default-values-from-shortcode-attributes
-
Hi – I’m following this documentation:
https://contactform7.com/getting-default-values-from-shortcode-attributes/And it is working with this in functions.php:
add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 ); function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) { $my_attr = 'zportal-doc'; if ( isset( $atts[$my_attr] ) ) { $out[$my_attr] = $atts[$my_attr]; } return $out; }
And using this url:
https://moldlawgroup.com/form-1/?zportal-doc=Landlord+CommunicationsAnd using this in the form:
<p class=”doc-title”>[text zportal-doc default:get]</p>Now, I would like to be able to add another shortcode attribute, how would I do that?
I would like to be able to use a link like this:
https://moldlawgroup.com/form-1/?zportal-doc=Landlord+Communications&form-id=F001
Where form-id would be different depending on which link the user clicked on the page.
Would I just need to add another function in functions.php file like this perhaps?:
add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter2', 10, 3 ); function custom_shortcode_atts_wpcf7_filter2( $out, $pairs, $atts ) { $my_attr = 'form-id'; if ( isset( $atts[$my_attr] ) ) { $out[$my_attr] = $atts[$my_attr]; } return $out; }
and in the form : [hidden form-id default:get]
Or is there a better way to do this in one function?
Thanks for any help you can provide.The page I need help with: [log in to see the link]
- The topic ‘getting-default-values-from-shortcode-attributes’ is closed to new replies.