Multiple shortcode attributes for contact form 7
-
I am using Contact Form 7 and have two hidden fields in the form. I am embedding the form in a custom template and want the hidden fields to show values passed through the shortcode.
The documentation shows how to add a single attribute to the shortcode, but how would I register multiple attributes?
add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 ); function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) { $my_attr = 'customer-email'; if ( isset( $atts[$my_attr] ) ) { $out[$my_attr] = $atts[$my_attr]; } return $out; }Template:
<?php echo do_shortcode( '[contact-form-7 id="151" title="Form" customer-name="ABC" customer-email="xxxxxx@example.com"]' ); ?>Contact Form 7:
[hidden customer-name default:shortcode_attr] [hidden customer-email default:shortcode_attr]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Multiple shortcode attributes for contact form 7’ is closed to new replies.