Skip to content

Instantly share code, notes, and snippets.

@greenhornet79
Created September 2, 2014 19:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenhornet79/2a8ad06249669e2e9093 to your computer and use it in GitHub Desktop.
Save greenhornet79/2a8ad06249669e2e9093 to your computer and use it in GitHub Desktop.
Add Gravity Forms data to custom database table
add_action('gform_after_submission', 'endo_add_entry_to_db', 10, 2);
function endo_add_entry_to_db($entry, $form) {
// uncomment to see the entry object
// echo '<pre>';
// var_dump($entry);
// echo '</pre>';
$source = $entry['source_url'];
$email = $entry[5];
$param1 = $entry[2];
$param2 = $entry[3];
global $wpdb;
// add form data to custom database table
$wpdb->insert(
'custom_table_name',
array(
'source_url' => $source,
'email' => $email,
'param1' => $param1,
'param2' => $param2,
'date' => current_time( 'mysql' )
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment