联系表格7 Hook for skip_mail

时间:2018-04-16 08:49:47

标签: wordpress paypal contact-form-7

我正在接触联系表7和PayPal& Stripe Add-on(用于Contact Form 7)插件。 在联系表单7上,我打开了其他设置skip_mail = on。 是否有可能创建一个挂钩来转动skip_mail = off并在人们已经通过PayPal&支付付款时从表单发送数据Stripe Add-on插件?

2 个答案:

答案 0 :(得分:0)

尝试以下代码行。

/*
    Prevent the email sending step for specific form and condition 
*/
add_action("wpcf7_before_send_mail", "wpcf7_do_something_else");  
function wpcf7_do_something_else($cf7) {
    // get the contact form object
    $wpcf = WPCF7_ContactForm::get_current();

    // if you wanna check the ID of the Form $wpcf->id

    if (/*Check whether user already paid the payment in the PayPal & Stripe Add-on plugin*/) {
        // If you want to skip mailing the data, you can do it...  
        $wpcf->skip_mail = true;    
    }

    return $wpcf;
}

答案 1 :(得分:0)

add_filter( 'wpcf7_skip_mail', function( $skip_mail, $contact_form ){
    $skip = ( $contact_form->id() == 111 ) // skip send mail if cf7_id = 111
    return $skip; // return true or false
}, 10, 2 );