Paste WordPress Gravity Form into a new spreadsheet

I have a WordPress site in which I use the gravitational form. I would like to take one of the forms of gravity that I use and paste the data into another table. (In addition to the table of gravitational form). I use Gravity Form after submitting to capture the values ​​of my specific form (3) and run the SQL statement. Here is the link explaining the hook: http://www.gravityhelp.com/documentation/page/Gform_after_submission

However, nothing is added to the new table (users). I can’t even tell if the script is working. The tables of the "default" form and the table of new users are in the same database. This is 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')";
   }

I grab values ​​using a Gravity Form input object. More on this here: http://www.gravityhelp.com/documentation/page/Entry_Object

The form is written to the default table, but not to my new "users" table. Any suggestions? Let me know if I need to provide more information. Thanks for any help!

+2
source share
3 answers

You have created a request but 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);
   }

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

+2
source

Try the following code ...

add_action('gform_after_submission_3', 'input_fields', 10, 2);
function input_fields($entry, $form){
global $wpdb;
               $name = $entry['1'];
               $email = $entry['2'];
               $purchase_date =  $entry['3'];
               $order_number = $entry['4'];

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

Thank....

+3
source

, .

. ?

0

All Articles