Using Gravity Forms ‘gform_after_create_post’ PHP action

The gform_after_create_post action hook in Gravity Forms is executed after a post has been created, and it only applies to forms that contain Post Fields.


To apply the action to all forms:

add_action( 'gform_after_create_post', 'your_function_name' );

To apply the action to a specific form, append the form id to the end of the hook name, like so (in this case for form id 6):

add_action( 'gform_after_create_post_6', 'your_function_name' );


  • $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 version 1.9.13.
  • $form (Form Object): The form currently being processed. Available from version 1.9.13.

More information

See Gravity Forms Docs: gform_after_create_post

Source Code: You can find the gform_after_create_post hook in the forms_model.php file, inside the GFFormsModel::create_post() function.

Version: This hook was implemented in Gravity Forms 1.9.13.


Updating the post content with submitted field values

In this example, the post content is updated with values from the form submission, including an image field.

add_action( 'gform_after_create_post', 'set_post_content', 10, 3 );
function set_post_content( $post_id, $entry, $form ) {
// Get the post
$post = get_post( $post_id );
// Update 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' ) . "'>";
// Save changes
wp_update_post( $post );

Converting a date to the format expected by ACF datepicker field type

This example demonstrates how to convert a Gravity Forms date field to the format expected by an ACF datepicker field type, and save it to a custom field.

add_action( 'gform_after_create_post_12', 'gf_date_to_acf', 10, 3 );
function gf_date_to_acf( $post_id, $entry, $form ) {
    // Date as saved by GF
    $gf_date = rgar( $entry, '30' );
// Date changed to format expected by ACF
$acf_date = date( 'Ymd', strtotime( $gf_date ) );
// Save converted date to the acf_date meta key
update_post_meta( $post_id, 'acf_date', $acf_date );

Updating a post custom field with serialized GF checkboxes

This example shows how to save the selections of a Gravity Forms checkboxes field in a post custom field as a serialized array, which is useful for plugins like Advanced Custom Fields (ACF), Types, and Pods.

add_filter( 'gform_after_create_post_1', 'gf_post_acf_checkboxes', 10, 3 );
function gf_post_acf_checkboxes( $post_id, $entry, $form ) {
    // Checkboxes field id
    $field_id = 18;
// Get field object
$field = GFAPI::get_field( $form, $field_id );
if ( $field-&gt;type == 'checkbox' ) {
// Get a comma separated list of checkboxes checked
$checked = $field-&gt;get_value_export( $entry );
// Convert to array
$values = explode( ', ', $checked );
// Update the custom field with the array of selected values
update_post_meta( $post_id, 'my_custom_field_key', $values );

Note: Make sure to replace 'my_custom_field_key' with your actual meta key and to place this code in the functions.php file of your active theme.