The gform_advancedpostcreation_post_after_creation action hook allows further actions to be performed after a post has been created using the Gravity Forms Advanced Post Creation Add-On.
Usage
To apply the hook to all forms, use the following code:
add_action('gform_advancedpostcreation_post_after_creation', 'your_function_name', 10, 4);
To target a specific form, append the form id to the hook name (format: gform_advancedpostcreation_post_after_creation_FORMID):
add_action('gform_advancedpostcreation_post_after_creation_1', 'your_function_name', 10, 4);
Parameters
$post_id
(int): The new post id.$feed
(Feed Object): The current feed object.$entry
(Entry Object): The current entry object.$form
(Form Object): The current form object.
More information
See Gravity Forms Docs: gform_advancedpostcreation_post_after_creation
Examples
Send notification after post creation
This example sends an email notification after the post has been created:
add_action('gform_advancedpostcreation_post_after_creation', 'after_post_creation', 10, 4); function after_post_creation($post_id, $feed, $entry, $form) { GFCommon::send_email('[email protected]', '[email protected]', '', '', 'New Post', 'A new post was created.'); }
Update a post custom field with serialized GF checkboxes
This example updates a post custom field with serialized Gravity Forms checkboxes. It is useful for plugins like Advanced Custom Fields (ACF), Types, and Pods where the values of the selections are stored in a serialized array. Update the form id and field id to match your form and field.
add_action('gform_advancedpostcreation_post_after_creation_1', 'apc_serialize_checkboxes', 10, 4); function apc_serialize_checkboxes($post_id, $feed, $entry, $form) { // Checkboxes field id. $field_id = 18; // Get field object. $field = GFAPI::get_field($form, $field_id); if ($field->type == 'checkbox') { // Get a comma-separated list of checkboxes checked $checked = $field->get_value_export($entry); // Convert to array. $values = explode(', ', $checked); } // Replace my_custom_field_key with your custom field meta key. update_post_meta($post_id, 'my_custom_field_key', $values); }