Using Gravity Forms ‘gform_advancedpostcreation_pre_update_post’ PHP action

The gform_advancedpostcreation_pre_update_post action allows custom actions to be performed before the post is updated in Gravity Forms.

Usage

A generic example of how to use the action:

add_action('gform_advancedpostcreation_pre_update_post', 'your_function_name', 10, 3);

function your_function_name($post, $feed, $entry) {
    // your custom code here
}

Parameters

  • $post (array) – The post to be updated. The array returned is from 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_pre_update_post

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

add_action('gform_advancedpostcreation_pre_update_post_1', 'your_function_name', 10, 3);

Examples

Modify the post title

Update the post title before the post is updated:

add_action('gform_advancedpostcreation_pre_update_post', 'modify_post_title', 10, 3);

function modify_post_title($post, $feed, $entry) {
    $post['post_title'] = 'Updated: ' . $post['post_title'];
}

Add a custom taxonomy term

Add a custom taxonomy term to the post before it’s updated:

add_action('gform_advancedpostcreation_pre_update_post', 'add_custom_taxonomy_term', 10, 3);

function add_custom_taxonomy_term($post, $feed, $entry) {
    wp_set_object_terms($post['ID'], 'example-term', 'example-taxonomy', true);
}

Add custom metadata

Add custom metadata to the post before it’s updated:

add_action('gform_advancedpostcreation_pre_update_post', 'add_custom_metadata', 10, 3);

function add_custom_metadata($post, $feed, $entry) {
    update_post_meta($post['ID'], 'custom_key', 'custom_value');
}

Change the post format

Change the post format before the post is updated:

add_action('gform_advancedpostcreation_pre_update_post', 'change_post_format', 10, 3);

function change_post_format($post, $feed, $entry) {
    set_post_format($post['ID'], 'aside');
}

Send an email notification

Send an email notification when a post is about to be updated:

add_action('gform_advancedpostcreation_pre_update_post', 'send_email_notification', 10, 3);

function send_email_notification($post, $feed, $entry) {
    $to = '[email protected]';
    $subject = 'Post Updated: ' . $post['post_title'];
    $message = 'A post has been updated on your website. Post ID: ' . $post['ID'];

    wp_mail($to, $subject, $message);
}