gform_admin_messages

gform_admin_messages

DescriptionUsageParametersExamplesPlacementSource Code

Description
Modify update (and other non-error) messages displayed by Gravity Forms in the WordPress admin.
Usage
1add_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.
123456789101112131415161718add_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 .= ' Preview Form';    }     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

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注