gform_disable_post_creation

gform_disable_post_creation

DescriptionUsageParametersExamples1. Disable for all forms2. Disable based on a field valuePlacementSource Code

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
1add_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.
1add_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:
1234add_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
12345add_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.

发表回复

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