bookmark_bordergform_admin_messages

Description

Modify update (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.

Examples

This example demonstrates how we can 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, let's not 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;
}

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in GFCommon::display_admin_message() in common.php