The gform_post_upgrade action hook in Gravity Forms fires after Gravity Forms has been fully upgraded, allowing further actions to be performed.
Usage
add_action('gform_post_upgrade', 'your_function_name', 10, 3);
Parameters
- $version (string) – The upgraded version of Gravity Forms.
- $from_db_version (string) – The version before the upgrade.
- $force_upgrade (bool) – True/false indicating if the upgrade was forced.
More information
See Gravity Forms Docs: gform_post_upgrade
Examples
Display an upgrade alert
This example shows how to display a message after Gravity Forms has been upgraded.
add_action('gform_post_upgrade', 'alert_upgrade', 10, 3); function alert_upgrade($version, $from_db_version, $force_upgrade) { echo 'Gravity Forms was upgraded from ' . $from_db_version . ' to ' . $version; }
Send an email notification after upgrade
This example sends an email notification to the site administrator after Gravity Forms has been upgraded.
add_action('gform_post_upgrade', 'send_upgrade_email', 10, 3); function send_upgrade_email($version, $from_db_version, $force_upgrade) { $to = get_option('admin_email'); $subject = 'Gravity Forms Upgrade Notification'; $message = 'Gravity Forms was upgraded from ' . $from_db_version . ' to ' . $version; wp_mail($to, $subject, $message); }
Run custom database queries after upgrade
This example runs a custom database query after Gravity Forms has been upgraded.
add_action('gform_post_upgrade', 'run_custom_queries', 10, 3); function run_custom_queries($version, $from_db_version, $force_upgrade) { global $wpdb; // Your custom query here $wpdb->query("UPDATE {$wpdb->prefix}your_table_name SET your_column_name = 'new_value'"); }
Update an option value after upgrade
This example updates a custom option value after Gravity Forms has been upgraded.
add_action('gform_post_upgrade', 'update_custom_option', 10, 3); function update_custom_option($version, $from_db_version, $force_upgrade) { update_option('your_custom_option_name', 'new_value'); }
Log upgrade information
This example logs Gravity Forms upgrade information in a custom log file.
add_action('gform_post_upgrade', 'log_upgrade', 10, 3); function log_upgrade($version, $from_db_version, $force_upgrade) { $log_message = 'Gravity Forms was upgraded from ' . $from_db_version . ' to ' . $version . ' on ' . date('Y-m-d H:i:s') . PHP_EOL; file_put_contents('your_log_file_path/upgrade.log', $log_message, FILE_APPEND); }