gform_disable_post_creation

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

    This example disables the post creation process for form 6 only. If field 2 in the entry does not contain the word ‘something’, post creation will be disabled for form 6.

    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 can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

    See also the PHP section in this article: Where Do I Put This Code?

    Source Code

    This filter is located in GFCommon::create_post() in common.php.