Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mikeott/5a33cc598c9dd47706c58af380168985 to your computer and use it in GitHub Desktop.
Save mikeott/5a33cc598c9dd47706c58af380168985 to your computer and use it in GitHub Desktop.
Insert Gravity Forms field entries into database table after form submission
/*
Add to functions.php
*/
add_action( 'gform_after_submission_2', 'capture', 10, 2 ); /* gform_after_submission_2 = form ID 2 */
function capture( $entry, $form ) {
global $wpdb;
$table= $wpdb->prefix . 'my_table';
$end_date = $entry['4']; /* Field ID 4 */
$email = $entry['2']; /* Field ID 2 */
$the_name = $entry['1']; /* Field ID 1 */
$wpdb->query( $wpdb->prepare(
"
INSERT INTO $table (
end_date,
email,
the_name,
notified
)
VALUES ( %d, %s, %s, %s )
",
array(
$end_date,
$email,
$the_name
)
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment