• Hey! We have been using this plugin and it works great! But in some cases we would like the emails not to be sent, so that the data only goes to a Google Sheet.

    We are using an external email service (Mailgun, Sendgrid, AWS SES etc.) and since we’re using the free plan we have a pretty low daily quota. This means that if we have high traffic on a form from Contact Form 7 that submits the data to a Google Sheet document, then there is also one email per submission. This makes us use up all our quota in no time. Due to this there was a need to prevent the emails from bein sent, and just post the data to the document. See below for my proposed code that could probably be implemented in the plugin, perhaps be added as an option on each form so that people could decide whether they want to have outgoing emails on a form that posts to a document. Thoughts? Do you have a Github repo that I can add a PR to, if you want.

    /**
     * Disable outgoing emails when using "Contact Form 7" and "CF7 Google Sheet Connector".
     *
     * @param $skip_mail
     * @param $contact_form
     * @return bool|mixed
     */
    function skip_email_when_using_cf7_google_sheet_connector($skip_mail, $contact_form) {
        if (!class_exists('\\WPCF7_Submission')) {
            return $skip_mail;
        }
        $submission = \WPCF7_Submission::get_instance();
        // get form data
        $form_id = $contact_form->id();
        $form_data = get_post_meta( $form_id, 'gs_settings' );
        // if contact form sheet name and tab name is not empty than send data to spreedsheet
        if ( $submission && (! empty( $form_data[0]['sheet-name'] ) ) && (! empty( $form_data[0]['sheet-tab-name'] ) ) ) {
            return true;
        }
        return $skip_mail;
    }
    add_filter('wpcf7_skip_mail', __NAMESPACE__ . '\\skip_email_when_using_cf7_google_sheet_connector', 10, 2);

    Kind regards
    Robert Sæther

The topic ‘Feature suggestion: prevent e-mail send’ is closed to new replies.