Conditional file attachments

The file field is a supported conditional field. But apart from simply showing/hiding groups based on the fact if a file is selected or not, you can also add files conditionally.

Attach files from your media library conditionally

Take this form as an example:

Now in the Mail tab, in the “File attachments” field enter this:

Note that, to add files from your library, you need to get the absolute path. i.e.: https://example.com/wp-content/uploads/2019/07/file-1.pdf, and only keep the part after https://example.com/wp-content/. So in this case the part you keep would be: uploads/2019/07/file-1.pdf

For security reasons, you are not allowed to add full URLs as file attachments. See CF7 documentation.

Attach user uploaded files

In most cases you would not need conditional logic to handle files uploaded by the user. But I’ll add an example for completeness.

The form:

In the “File attachments” field add this:

Only non-empty file fields will be added to attachments, so no need to specify conditions in this case. This is the default CF7 behavior.

File

Form

Select a file and some text should appear here:

Some text

Form Code

[file filefield]

Select a file and some text should appear here:

[group group-file]
<strong>Some text</strong>
<br>
[/group]

Conditional Fields

show group if field operator value

group-file if filefield not equals  

questionnaire 2

Show fields one by one

This example shows how you can use Conditional Fields for Contact Form 7 to create a form that will force the user to fill in fields in a particular order by only displaying the next field if the previous field is filled out. In this example all fields remain visible and editable after they are filled out. In some cases you might want a field to disappear after it is filled, and then display a new field. This can also be achieved with CF7CF. An example of this is questionnaire 1.

Form

Question 1: Hi, how are you?

Question 2: What is your favorite color?

Question 3: What is your least favorite color?

Question 4: Do you like my website?

Question 5: Do you like this plugin?

Question 6: Do you like random questions?

Question 7: How the hell are you supposed to answer this question?

Question 8: Wow! You made it pretty far already, seems like you really enjoy filling out this questionnaire, don't you?

Question 9: One more question after this one. Okay?

Question 10: Just answer yes or no and the submit button will appear!

 

Form Code

Question 1: Hi, how are you?
[select q1 "---" "I'm great" "I'm fine" "Not so well"]

[group g2]
Question 2: What is your favorite color?
[select q2 "---" "red" "blue" "yellow" "something else"]

[group g3]
Question 3: What is your least favorite color?
[select q3 "---" "red" "blue" "yellow" "something else"]

[group g4]
Question 4: Do you like my website?
[select q4 "---" "yes" "no"]

[group g5]
Question 5: Do you like this plugin?
[select q5 "---" "yes" "no"]

[group g6]
Question 6: Do you like random questions?
[select q6 "---" "yes" "no"]

[group g7]
Question 7: How the hell are you supposed to answer this question?
[select q7 "---" "yes" "no"]

[group g8]
Question 8: Wow! You made it pretty far already, seems like you really enjoy filling out this questionnaire, don't you?
[select q8 "---" "yes" "no"]

[group g9]
Question 9: One more question after this one. Okay?
[select q9 "---" "yes" "no"]

[group g10]
Question 10: Just answer yes or no and the submit button will appear!
[select q10 "---" "yes" "no"]

[group gsubmit]
[submit]<p>&nbsp;</p>
[/group][/group][/group][/group][/group][/group][/group][/group][/group][/group]

Email Code

q1: [q1]
q2: [q2]
q3: [q3]
q4: [q4]
q5: [q5]
q6: [q6]
q7: [q7]
q8: [q8]
q9: [q9]
q10: [q10]

Conditional Fields

show group if field operator value

g2 if q1 not equals --- 
g3 if q2 not equals --- 
g4 if q3 not equals --- 
g5 if q4 not equals --- 
g6 if q5 not equals --- 
g7 if q6 not equals --- 
g8 if q7 not equals --- 
g9 if q8 not equals --- 
g10 if q9 not equals --- 
gsubmit if q10 not equals --- 

simple form

Form

wanna fill out some required fields? noyes


Form Code

wanna fill out some required fields? [radio radio-430 default:1 "no" "yes"]
[group name]
<label> Your Name (required)
    [text* your-name] </label>
<label> Your Email (required)
    [email* your-email] </label>
[/group]

<label> Subject
    [text your-subject] </label>

<label> Your Message
    [textarea your-message] </label>

[submit "Send"]

Email Code

From: [your-name] <[your-email]><br>
Subject: [your-subject]<br>
<br><br>
Message Body:
[your-message]
<br><br>
-- 
This e-mail was sent from a contact form on Contact Form 7 Conditional Fields (https://conditional-fields-cf7.bdwm.be)

Conditional Fields

show group if field operator value

name if radio-430 equals yes 

questionnaire 1

Show fields one by one and hide completed fields

This example shows how you can use Conditional Fields for Contact Form 7 to create a form that will force the user to fill in fields in a particular order by only displaying the next field if the previous field is filled out. In this example the fields disappear after they are filled, and then display a new field. In some cases you might want all fields to remain visible and editable after they are filled out. This can also be achieved with CF7CF. An example of this is questionnaire 2.

Form

Question 1: Hi, how are you?
Question 2: What is your favorite color?
Question 3: What is your least favorite color?
Question 4: Do you like my website?
Question 5: Do you like this plugin?
Question 6: Do you like random questions?
Question 7: How the hell are you supposed to answer this question?
Question 8: Wow! You made it pretty far already, seems like you really enjoy filling out this questionnaire, don't you?
Question 9: One more question after this one. Okay?
Question 10: Just answer yes or no and the submit button will appear!

 

Form Code

[group g1]
Question 1: Hi, how are you?
[select q1 "---" "I'm great" "I'm fine" "Not so well"]
[/group]

[group g2][group g2sub]
Question 2: What is your favorite color?
[select q2 "---" "red" "blue" "yellow" "something else"]
[/group][/group]

[group g3][group g3sub]
Question 3: What is your least favorite color?
[select q3 "---" "red" "blue" "yellow" "something else"]
[/group][/group]

[group g4][group g4sub]
Question 4: Do you like my website?
[select q4 "---" "yes" "no"]
[/group][/group]

[group g5][group g5sub]
Question 5: Do you like this plugin?
[select q5 "---" "yes" "no"]
[/group][/group]

[group g6][group g6sub]
Question 6: Do you like random questions?
[select q6 "---" "yes" "no"]
[/group][/group]

[group g7][group g7sub]
Question 7: How the hell are you supposed to answer this question?
[select q7 "---" "yes" "no"]
[/group][/group]

[group g8][group g8sub]
Question 8: Wow! You made it pretty far already, seems like you really enjoy filling out this questionnaire, don't you?
[select q8 "---" "yes" "no"]
[/group][/group]

[group g9][group g9sub]
Question 9: One more question after this one. Okay?
[select q9 "---" "yes" "no"]
[/group][/group]

[group g10][group g10sub]
Question 10: Just answer yes or no and the submit button will appear!
[select q10 "---" "yes" "no"]
[/group][/group]

[group gsubmit]
[submit]
[/group]
<p>&nbsp;</p>

Email Code

q1: [q1]
q2: [q2]
q3: [q3]
q4: [q4]
q5: [q5]
q6: [q6]
q7: [q7]
q8: [q8]
q9: [q9]
q10: [q10]

Conditional Fields

show group if field operator value

g1 if q1 equals --- 
g2 if q2 equals --- 
g2sub if q1 not equals --- 
g3 if q3 equals --- 
g3sub if q2 not equals --- 
g4 if q4 equals --- 
g4sub if q3 not equals --- 
g5 if q5 equals --- 
g5sub if q4 not equals --- 
g6 if q6 equals --- 
g6sub if q5 not equals --- 
g7 if q7 equals --- 
g7sub if q6 not equals --- 
g8 if q8 equals --- 
g8sub if q7 not equals --- 
g9 if q9 equals --- 
g9sub if q8 not equals --- 
g10 if q10 equals --- 
g10sub if q9 not equals --- 
gsubmit if q10 not equals --- 

multistep

Conditional Fields for Contact Form 7 is fully compatible with these Multistep plugins:

Form

Would you like to show group 1?

Group 1 is shown

Form Code

Would you like to show group 1? [select* menu-show-group-1 include_blank "maybe" "yes" "no"]

[group group-1]
Group 1 is shown
[/group]

[submit "next step"]

[multistep "1-3-https://conditional-fields-cf7.bdwm.be/multistep-step-2"]

Conditional Fields

show group if field operator value

group-1 if menu-show-group-1 equals yes 

Popup Test

Click here to open the popup

 

How to do this yourself?

  1. Install Popup Maker
  2. Create your contact form
  3. Go to the WP Admin Panel > Popup Maker > Add Popup
  4. Choose a name and a title, and add your Contact Form 7 shortcode in the content area
  5. Under Triggers click Add Trigger and choose Click Trigger
  6. Publish the Popup, go to Popup Maker> All Popups and take note of the ID.
  7. Create a new page and add this shortcode: [popup_trigger id="{ID}" tag="a"]Click here to open the popup[/popup_trigger] (replace {ID} with your popup ID)