Skip to main content

Setting Up Conditional Recipients in Divi Form Builder

Conditional recipients allow you to send form submissions to different email addresses based on certain conditions. This is useful for directing form responses to the appropriate departments or individuals, ensuring that communications are efficiently managed.

What You Will Need

To set up conditional recipients, you need the Form ID and the IDs of the fields you want to use in your conditions. These IDs are unique identifiers for your form and fields.

  1. Form ID: Edit your Divi Form Builder module and within the Main Options setting, add or copy the Form ID.
  2. Field ID(s): Edit your Divi Form Builder module, open the settings for the relevant field, and add or copy the Field ID under Field Options.
note

You can use as many fields as you like, and they can be any field type. It's recommended to use fields with pre-defined options such as Select, Checkbox, or Radio fields for predictable values.

Step 1: Create and Add Your Conditional Recipient Function

Single Field Conditional Code

The below example of code needs to be added to your child themes function.php file. You need to replace the $form_id with the Form ID you have defined in the previous step. The $form_data sets your Field ID and the condition has to be exactly as it is defined in your form.

For this example, we have a Select field with the options Sales and Support.

Multiple Field Conditional Code

You can also create conditions based on multiple field values!

The below example of code needs to be added to your child themes function.php file. You need to replace the $form_id with the Form ID you have defined in the previous step. The $form_data sets your Field ID and the condition has to be exactly as it is defined in your form.

For this example, we have a Select field with the options Sales and Support and a Select Field for our products.

Multiple Forms With Different Conditions Code

You can use this code with multiple forms that have different conditions.

No Conditions Met?

If none of the conditions you define are met, the standard form recipient defined in your Form Builder Form Module will be used.

Step 2: Add Your Filter

Add the filter to your functions.php file to enable your function to interact with the form process.

If you have multiple forms and some are contact forms while others are different types, rename your filter and adjust the function name in the filter.

Example:

Additional Tips

By following these steps, you can effectively set up conditional recipients for your Divi Form Builder forms, ensuring the right people receive the appropriate form submissions.