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;


<?php echo do_shortcode( '[contact-form-7 id="151" title="Form" customer-name="ABC" customer-email=""]' ); ?>

Contact Form 7:

[hidden customer-name default:shortcode_attr] 

[hidden customer-email default:shortcode_attr] 

Read more here: Multiple shortcode attributes for contact form 7

Leave a Reply

Your email address will not be published. Required fields are marked *