WordPress将重力表格数据插入新表 [英] WordPress insert Gravity Form data into new table

查看:105
本文介绍了WordPress将重力表格数据插入新表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WordPress网站,我使用重力形式。我想采取我使用的一种重力形式,并将数据插入另一个表。 (除重力式表外)。我在提交钩子后使用重力形式来抓取我的具体形式的值(3)并运行一个SQL语句。以下是解释有关该问题的链接: http://www.gravityhelp.com/documentation/page/ Gform_after_submission

I have a WordPress site that I am using a gravity form. I would like to take one of the gravity forms I am using and insert the data into another table. (Besides the gravity form table). I am using the Gravity Form after submission hook to grab the values of my specific form (3) and run a SQL statement. Here is a link explaining about the hook: http://www.gravityhelp.com/documentation/page/Gform_after_submission

但是,没有任何内容插入新表(用户)。我甚至不能告诉脚本是否正在运行。 默认重力形式表和我的新用户表都在同一个数据库中。这是我的PHP看起来像:

However, nothing gets inserted into the new table (users). I can't even tell if the script is running. Both the "default" gravity form table and my new users table are in the same database. Here's what my PHP looks like:

add_action("gform_after_submission_3", "input_fields", 10, 2);
function input_fields($entry, $form){


                    $entry["1"] = '$name';
                    $entry["2"] = '$email';
                    $entry["3"] = '$purchase_date';
                    $entry["4"] = '$order_number';

   $SQL = "INSERT INTO users ( userID, email, name, purchase_date, order_number) VALUES ( '', '$email' , '$name', '$purchase_date', '$order_number')";
   }



我使用Gravity Form条目对象获取值。有关此处的详情: http://www.gravityhelp.com/documentation/page/Entry_Object

表单写入默认表,但不是我的新users表。有什么建议么?让我知道,如果我需要给更多的信息。非常感谢您的帮助!

The form writes to the default table alright but not to my new "users" table. Any suggestions? Let me know if I need to give more info. Thanks for any help!

推荐答案

您已经创建了查询,但是没有执行。

You have created the query but you are not executing it.

add_action("gform_after_submission_3", "input_fields", 10, 2);
function input_fields($entry, $form){
    global $wpdb;


                    $entry["1"] = '$name';
                    $entry["2"] = '$email';
                    $entry["3"] = '$purchase_date';
                    $entry["4"] = '$order_number';

   $SQL = "INSERT INTO users ( userID, email, name, purchase_date, order_number) VALUES ( '', '$email' , '$name', '$purchase_date', '$order_number')";
   $wpdb->query($SQL);
   }

此外,我假设您已经创建了 >表。

Also I assume that you have already created the users table.

这篇关于WordPress将重力表格数据插入新表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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