DescriptionUsageParametersExamplesPlacementSource Code
Description
By default, the 「Add Form」 button will only be displayed on the Post or Page edit screens. Use this filter to allow the 「Add Form」 button to be displayed on other pages.
Note: The 「Add Form」 button requires a TinyMCE input, so in order to display it, you must first include a TinyMCE input to your page.
Usage
add_filter( 'gform_display_add_form_button', 'display_form_button_on_custom_page' );
Parameters
$is_post_edit_page bool
True if the current page is a Post or Page edit page. False otherwise.
$is_post_edit_page = in_array( RG_CURRENT_PAGE, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php', 'customize.php' ) );
Examples
This example enables the 「Add Form」 button on a custom page whose URL contains the following query string: 「page=my_page」.
add_filter( 'gform_display_add_form_button', 'display_form_button_on_custom_page' );
function display_form_button_on_custom_page( $is_post_edit_page ) {
if ( isset( $_GET['page'] ) && $_GET['page'] == 'my_page' ) {
return true;
}
return $is_post_edit_page;
}
Simple example to disable button.
add_filter( 'gform_display_add_form_button', '__return_false' );
This example enables the 「Add Form」 button if the page is not a post page.
add_filter( 'gform_display_add_form_button', function ( $is_post_edit_page ) {
global $current_screen;
return $current_screen instanceof WP_Screen && $current_screen->base != 'post' ? true : $is_post_edit_page;
} );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFForms::page_supports_add_form_button() in gravityforms.php.