Solution 1 :

For selected default option you need to add “default” to checkbox field.

I make an example:
if you want checkbox-1 selected default to “Option 1” you need to add default:1

[checkbox checkbox-1 default:1 “Option 1” “Option 2”]

Let me know

Solution 2 :

Ok, I got it one part using the contact form default values from shortcode attributes

For example, let’s say you have a field named “checkbox-1” for the checkbox-1:

[checkbox* checkbox-1]
To get the default value from shortcode attributes, add the default:shortcode_attr option to the form-tag:

[checkbox* checkbox-1 default:shortcode_attr]
Then, add an attribute with the same name as the field (“checkbox-1” in this case) into the shortcode for the contact form:

[contact-form-7 id=”123″ title=”Contact Form” checkbox-1= “Option 1”]

Add the following code snippet to your theme’s functions.php file:

add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 );

function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) { 
$my_attr = 'destination-email';

if ( isset( $atts[$my_attr] ) ) {
$out[$my_attr] = $atts[$my_attr];
return $out;

This step is working.

Can I have a second attribute?
I don’t know how to code in PHP and add the option to have a second attribute.

Problem :

I’ve created a contact form 7 form, with the plugin for the conditional fields.

I’d like to know if it is possible to have a shortcode of the form with already some options selected.

Like below:

<label> Name (*)
    [text* your-name] </label>

<label> Email (*)
    [email* your-email] </label>

<label> Phone
    [tel* tel-1] </label>

[checkbox checkbox-1 exclusive "Option 1" "Option 2"]

[group group-1][checkbox* checkbox-2 exclusive "Option A" "Option  B" "Option C" "Option D"][/group]

[submit "Submit"]

The objective will be to have a shortcode to the form with for example the Option 2 and Option D already selected.


Comment posted by Akshay Shah

Are you using any addon of cf7?

Comment posted by How do I ask a good question

Welcome to Stack Overflow. What have you already tried yourself to do this? Please review

Comment posted by Rob

Thank you for your replies. The only plugin that I’m using aditional to Contact Form 7 is the Contact Form 7 Conditional Fields.

Comment posted by Rob

Thank you very much for your answer. My plan is to have a contact form shortcode with each option slected for example. I wan to have a shortcode [contact-form-7 id=”4032″ title=”Contact Form”] with checkbox-1 “Option-2” and checkbox-2 “Option B” selected Then I could add another shortcode with [contact-form-7 id=”4032″ title=”Contact Form”] with checkbox-1 “Option-1” and checkbox-2 “Option C” selected On that case I wouldn’t need to create each contact form with a default option checked and would only need to change the shortcode. I hope this makes sense.


Leave a Reply

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