Skip to content

Instantly share code, notes, and snippets.

@joemaller
Created October 10, 2024 17:09
Show Gist options
  • Save joemaller/3db6278652a08237bc6a053dd3853ef6 to your computer and use it in GitHub Desktop.
Save joemaller/3db6278652a08237bc6a053dd3853ef6 to your computer and use it in GitHub Desktop.
Function to validate Gravity Forms gf_token save tokens for accessing in-progress forms
<?php
function validateGF_Token($token)
{
global $wpdb;
$gf_drafts_table = $wpdb->prefix . 'gf_draft_submissions';
$table_check = $wpdb->get_var("SHOW TABLES LIKE '{$gf_drafts_table}'");
if ($table_check !== $gf_drafts_table) {
return false;
}
$query = "SELECT * FROM $gf_drafts_table WHERE uuid = %s";
$prepared_query = $wpdb->prepare($query, $token);
$results = $wpdb->get_results($prepared_query);
return count($results) > 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment