The gform_addon_app_PAGE_TAB action in Gravity Forms triggers when a specific page and tab within the Gravity Forms user interface is accessed. This action is commonly used for adding custom content to specific settings tabs.
Usage
Here’s a simplified way to use this action:
add_action( 'gform_addon_app_PAGE_TAB', 'your_function_name' );
In this code, your_function_name is where you’ll place the name of your own function.
Parameters
The gform_addon_app_PAGE_TAB action doesn’t have any parameters.
More information
To get more details about this action, refer to the Gravity Forms Documentation: gform_addon_app_PAGE_TAB
This action is located in the class-gf-addon.php file.
Examples
Adding a Simple Message
To add a simple message whenever a user accesses a particular page and tab:
function add_my_message() {
echo "Welcome to this page!";
}
add_action( 'gform_addon_app_PAGE_TAB', 'add_my_message' );
This will display the message “Welcome to this page!” on the accessed tab.
Inserting Custom HTML
To insert custom HTML on the page:
function insert_custom_html() {
echo "<div>Welcome to our custom settings page!</div>";
}
add_action( 'gform_addon_app_PAGE_TAB', 'insert_custom_html' );
The code will add a div with the message “Welcome to our custom settings page!”.
Displaying User Information
To show user information:
function show_user_info() {
$current_user = wp_get_current_user();
echo 'Username: ' . $current_user->user_login;
}
add_action( 'gform_addon_app_PAGE_TAB', 'show_user_info' );
This will display the username of the currently logged-in user.
Adding Custom CSS
To add custom CSS:
function add_custom_css() {
echo '<style>body {background-color: lightblue;}</style>';
}
add_action( 'gform_addon_app_PAGE_TAB', 'add_custom_css' );
This will change the background color of the page to light blue.
Adding a Custom Warning
To add a custom warning message:
function add_warning_message() {
echo "<p class='warning'>Please make sure to save your changes!</p>";
}
add_action( 'gform_addon_app_PAGE_TAB', 'add_warning_message' );
This will display a warning message to the user, reminding them to save their changes.