【问题标题】:Contact Form 7 Hook for skip_mail联系表格 7 钩子以获取 skip_mail
【发布时间】:2018-09-25 22:46:20
【问题描述】:

我正在使用 Contact Form 7 和 PayPal & Stripe Add-on(用于 Contact Form 7)插件。 在联系表 7 上,我打开了附加设置 skip_mail = on。 当人们已经在 PayPal & Stripe Add-on 插件中付款时,是否可以创建一个钩子来打开 skip_mail = off 并从表单发送数据?

【问题讨论】:

    标签: wordpress paypal contact-form-7


    【解决方案1】:

    试试下面的代码。

    /*
        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;
    }
    

    【讨论】:

      【解决方案2】:
      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 );
      

      【讨论】:

      • 请在您的代码中添加注释并解释其工作原理
      • 最好在此处包含答案的基本部分,并提供链接以供参考,以防目标页面不可用或发生更改。
      猜你喜欢
      • 1970-01-01
      • 2016-08-12
      • 1970-01-01
      • 1970-01-01
      • 2015-06-05
      • 1970-01-01
      • 1970-01-01
      • 2020-05-30
      • 2017-03-16
      相关资源
      最近更新 更多