Using Gravity Forms ‘gform_advancedpostcreation_update_post_data’ PHP filter

The gform_advancedpostcreation_update_post_data filter allows you to modify the post data before updating it in Gravity Forms.

Usage

To apply the filter to all forms:

add_filter('gform_advancedpostcreation_update_post_data', 'your_function_name', 10, 3);

To target a specific form, append the form id to the hook name (format: gform_advancedpostcreation_update_post_data_FORMID):

add_filter('gform_advancedpostcreation_update_post_data_1', 'your_function_name', 10, 3);

Note that only files uploaded using the Gravity Forms File Upload field will be updated.

Parameters

  • $post (array) – The post array being updated. Array returned is the WP get_post function.
  • $feed (Feed Object) – The feed being processed.
  • $entry (Entry Object) – The entry linked to the post.

More information

See Gravity Forms Docs: gform_advancedpostcreation_update_post_data

Examples

Modify Post Title

Update the post title by adding a prefix:

add_filter('gform_advancedpostcreation_update_post_data', 'modify_post_title', 10, 3);
function modify_post_title($post, $feed, $entry) {
    $post['post_title'] = 'Prefix - ' . $post['post_title'];
    return $post;
}

Update Post Content

Append extra content to the post content:

add_filter('gform_advancedpostcreation_update_post_data', 'update_post_content', 10, 3);
function update_post_content($post, $feed, $entry) {
    $post['post_content'] .= ' Additional content.';
    return $post;
}

Change Post Status

Change the post status based on a form field value:

add_filter('gform_advancedpostcreation_update_post_data', 'change_post_status', 10, 3);
function change_post_status($post, $feed, $entry) {
    if ($entry[1] == 'Yes') {
        $post['post_status'] = 'draft';
    }
    return $post;
}

Add Post Meta

Add custom meta data to the post:

add_filter('gform_advancedpostcreation_update_post_data', 'add_post_meta_data', 10, 3);
function add_post_meta_data($post, $feed, $entry) {
    $post_meta_key = 'custom_meta_key';
    $post_meta_value = $entry[2];
    update_post_meta($post['ID'], $post_meta_key, $post_meta_value);
    return $post;
}

Remove Post Thumbnail

Remove the post thumbnail from the post:

add_filter('gform_advancedpostcreation_update_post_data', 'remove_post_thumbnail', 10, 3);
function remove_post_thumbnail($post, $feed, $entry) {
    delete_post_thumbnail($post['ID']);
    return $post;
}