Description
Use this filter to disable post creation when submitting a Gravity Form.
Note: This filter is intended for use with Gravity Forms built-in Post creation feature, it doesn’t support the Advanced Post Creation add-on.
Usage
add_filter( 'gform_disable_post_creation', 'disable_post_creation', 10, 3 );
You can also specify this per form by adding the form id after the hook name.
add_filter( 'gform_disable_post_creation_6', 'disable_post_creation', 10, 3 );
Parameters
- $is_disabled bool
Variable to be filtered. Set it to true to prevent posts from being created.
-
$form Form Object
Current form.
-
$entry Entry Object
Current Entry array.
Examples
1. Disable for all forms
This example disables the post creation process for all forms:
add_filter( 'gform_disable_post_creation', 'disable_post_creation', 10, 3 ); function disable_post_creation( $is_disabled, $form, $entry ) { return true; }
2. Disable based on a field value
add_filter( 'gform_disable_post_creation_6', 'disable_post_creation', 10, 3 ); function disable_post_creation( $is_disabled, $form, $entry ) { $is_disabled = rgar( $entry, '2' ) != 'something' ? true : $is_disabled; return $is_disabled; }
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCommon::create_post() in common.php.