bookmark_bordergform_after_create_post

Description

This action hook is executed after the post has been created. It only applies to forms that have Post Fields.

Usage

The following would apply to all forms.

add_action( 'gform_after_create_post', 'your_function_name' );

To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_after_create_post_FORMID)

add_action( 'gform_after_create_post_6', 'your_function_name' );

Parameters

  • $post_id integer

    The ID of the post which was created from the form submission.

  • $entry Entry Object

    The entry currently being processed. Available from 1.9.13.

  • $form

    The form currently being processed. Available from 1.9.13.

Examples

1. Update the Post

This example shows how you can update the post content, adding values from submitted fields, including an image field.

add_action( 'gform_after_create_post', 'set_post_content', 10, 3 );
function set_post_content( $post_id, $entry, $form ) {

    //getting post
    $post = get_post( $post_id );

    //changing post content
    $post->post_content = 'Blender Version:' . rgar( $entry, '7' ) . "<br/> <img src='" . rgar( $entry, '8' ) . "'> <br/> <br/> " . rgar( $entry, '13' ) . " <br/> <img src='" . rgar( $entry, '5' ) . "'>";

    //updating post
    wp_update_post( $post );
}

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

gf_do_action( 'gform_after_create_post', $form['id'], $post_id, $lead, $form )

This hook is located in GFFormsModel::create_post() in forms_model.php

Since

The form specific version of this hook was added in Gravity Forms 1.9.13.