Halloween Sale 15% off Ends in See the plans
PHP

Don't Email Submissions of Certain Contact Form 7 Forms

Stops Contact Form 7 sending emails for the forms you list while still showing the success message, useful when submissions are saved or sent to a CRM instead.

Don’t have WPIDE yet? Install it on your site

Code

$wpide_cf7_no_mail_forms = array(); // Form IDs that should not send email, e.g. array( 123, 456 ).

add_filter( 'wpcf7_skip_mail', function ( $skip, $contact_form = null ) use ( $wpide_cf7_no_mail_forms ) {
    if ( $contact_form && in_array( (int) $contact_form->id(), array_map( 'intval', $wpide_cf7_no_mail_forms ), true ) ) {
        return true;
    }

    return $skip;
}, 10, 2 );

Notes

Add the form IDs at the top and pair it with a snippet that saves submissions or sends them to a webhook, otherwise the messages are lost.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.