首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PayPal帮助(WPForms + Wordpress工作流)

PayPal帮助(WPForms + Wordpress工作流)
EN

Stack Overflow用户
提问于 2020-01-26 07:22:09
回答 1查看 135关注 0票数 0

上下文:我已经使用Wordpress中的WPForms插件为我的客户创建了一个自定义捐赠表单。客户希望通过PayPal接受捐赠。

问题: WPForms有一个PayPal附加功能,但它的价格是200美元。

问题为了避免为昂贵的插件支付$200,我如何手动将用户输入的WPForm数据(姓名、电子邮件、地址、捐款金额和就业信息)直接/邮寄到PayPal?

EN

回答 1

Stack Overflow用户

发布于 2020-01-26 11:54:15

在下面的示例代码中,我们首先检查表单ID,以确保它与目标表单匹配。然后我们检查一个特定的字段(通过字段ID),看看它是否为空。

只需记住将表单ID从5更改为与您的表单ID相匹配,并将“4”更改为与您的字段ID相匹配。

代码语言:javascript
复制
function wpf_dev_process( $fields, $entry, $form_data ) {

    // Optional, you can limit to specific forms. Below, we restrict output to
    // form #5.
    if ( absint( $form_data['id'] ) !== 5 ) {
        return $fields;
    }

    // check the field ID 4 to see if it's empty and if it is, run the error    
    if(empty($fields[4]['value'])) 
        {
            // Add to global errors. This will stop form entry from being saved to the database.
            // Uncomment the line below if you need to display the error above the form.
            // wpforms()->process->errors[ $form_data['id'] ]['header'] = esc_html__( 'Some error occurred.', 'plugin-domain' );    

            // Check the field ID 4 and show error message at the top of form and under the specific field
               wpforms()->process->errors[ $form_data['id'] ] [ '4' ] = esc_html__( 'Some error occurred.', 'plugin-domain' );

            // Add additional logic (what to do if error is not displayed)
        }
    }
add_action( 'wpforms_process', 'wpf_dev_process', 10, 3 );
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59914259

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档