• Hi.
    After few days of tries we have converted the function we had developed and were running up to cf 3.8.1. An hard work also because there is not documentation (an dexemple) how use the changes that has been introduced from 3.9. Tries -> errors, retries -> errors and so on…but now all is working apart a thing….. wpcf7_skip_mail

    in our code there was a thing like:

    if (condition)
    {
    $wpcf7->skip_mail = 1;
    return $wpcf7;
    }
    else
    {
    return $wpcf7;
    }

    now I have this thing… wpcf7_skip_mail but I don’t know how use it.
    I’ve found this exemple….but is not clear

    function my_skip_mail($f){
    $submission = WPCF7_Submission::get_instance();
    if(/* YOUR TEST HERE */){
    return true; // DO NOT SEND E-MAIL
    }
    }
    add_filter(‘wpcf7_skip_mail’,’my_skip_mail’);

    how to port it into our code since I don’t know eher add this filer and so on.
    Why complicate things in this way?

    Any idea?
    thankyou

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 6 replies - 1 through 6 (of 6 total)
  • I have the same problem, do you resolve your issue after all?

    i’ll try the filter:

    add_filter('wpcf7_skip_mail','my_skip_mail');
    
    function my_skip_mail($f){
    $submission = WPCF7_Submission::get_instance();
    return true;
    }

    But doesn’t work for me,

    Thread Starter pubblivori

    (@pubblivori)

    I?m sorry, not solved yet…. I think only the developer can do a clear exemple on how to use it….

    Ok, on the last CF7 version the filter works (i had the 3.9.1 version), this code works now:

    add_filter('wpcf7_skip_mail','my_skip_mail');
    
    function my_skip_mail($f){
    $submission = WPCF7_Submission::get_instance();
    return true;
    }

    and the email is not sent, but i have a function to the action wpcf7_before_send_mail, before i was using in this function:

    $posted_data->skip_mail = true;

    to block the email sent, but now how i can make use to the new filter?

    if i do in my wpcf7_before_send_mail function:

    $posted_data["skip_mail"] = true;

    and in the filter i do:

    function my_skip_mail($f){
        $submission = WPCF7_Submission::get_instance();
        $posted_data = $submission->get_posted_data();
        ob_start();                // start buffer capture
        var_dump( $posted_data );      // dump the values
        $contents = ob_get_contents(); // put the buffer into a variable
        ob_end_clean();                // end capture
        error_log( $contents );        // log contents of the result of var_dump( $object )
        if( $posted_data["skip_mail"] == 'true' ){
            return true; // DO NOT SEND E-MAIL
        }
    }

    On the error_log file the content of $posted_data don’t have the skip_mail element and i can’t compare anything to block the email sending.

    Fixed, the filter function:

    function my_skip_mail($f){
        if( $posted_data["skip_mail"] == 'true' ){
            return true; // DO NOT SEND E-MAIL
        }
    }

    you don’t need:

    $submission = WPCF7_Submission::get_instance();
        $posted_data = $submission->get_posted_data();

    If you use that, $posted_data will be rewrited and you lose the skip_mail key on the array.

    false alarm, you can’t get $posted_data with new params added on wpcf7_before_send_mail from the wpcf7_skip_mail filter

    @richzendy and how did you fix this?

    I have still a similar situation. In my case i don’t think this works

    function testFunction($WPCF7_ContactForm) {
     $wpcf7 = WPCF7_ContactForm::get_current();
    
            $submission = WPCF7_Submission::get_instance();
            if ($submission) {
                $posted_data = $submission->get_posted_data();
    //            print_r($posted_data);
    //            die();
            }
     $wpcf7 = WPCF7_ContactForm::get_current();
                $wpcf7->skip_mail = true;// doesn't work??

    i also set in submission.php private $skip_mail = false;

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘wpcf7_skip_mail, how use it?’ is closed to new replies.