WordPress帮助(WPForms + PayPal工作流程) [英] Wordpress Help (WPForms + PayPal Workflow)

查看:80
本文介绍了WordPress帮助(WPForms + PayPal工作流程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

CONTEXT: I’ve used the WPForms plugin in Wordpress to create a custom donation form for my client. The client wants to accept donations via PayPal.

问题:WPForms具有PayPal附加功能,但价格为200美元.

PROBLEM: WPForms has a PayPal add-on feature but it costs $200.

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

QUESTION To avoid paying $200 for the expensive plugin, how can I manually direct/post the WPForm data entered by the user (name, email, address, donation amount, and employment info) to PayPal?

推荐答案

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

In the example code you’ll see below, we’re first checking the form ID to make sure it matches the form that’s being targeted. Then we’re checking a specific field (by the field ID) to see if it’s empty.

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

Just remember to change the form ID from 5 to match your form ID and change the '4' to match your field ID.

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 );

这篇关于WordPress帮助(WPForms + PayPal工作流程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆