The gform_admin_messages Gravity Forms action allows you to modify update messages (and other non-error messages) displayed by Gravity Forms in the WordPress admin.
Usage
add_action('gform_admin_messages', 'my_custom_function');
Parameters
- $messages (array): An array of messages to be displayed below the title on Gravity Form pages.
More information
See Gravity Forms Docs: gform_admin_messages
Examples
Append a ‘Preview Form’ link to update messages
This example demonstrates how to append a ‘Preview Form’ link to any update message where a form ID is available in the query string.
add_action('gform_admin_messages', 'my_append_preview_form_link'); function my_append_preview_form_link($messages) { // Get the form ID from the query string $form_id = rgget('id'); // If no form ID is available, don't add the 'Preview Form' link if (!$form_id) { return; } // Loop through our error messages and append the 'Preview Form' link foreach ($messages as &$message) { $message .= ' <a href="' . site_url() . '/?gf_page=preview&id=' . $form_id . '">Preview Form</a>'; } return $messages; }
Place this code in the functions.php
file of your active theme.