gform_advancedpostcreation_post

gform_advancedpostcreation_post

DescriptionUsageParametersExamplesChange the post contentChange the post slugChange the post excerptPlacementSinceSource Code

Description

Modifies the Post object before it is created.

Note: This filter should not be used to override the Post ID value. Doing it would cause unexpected results during the Post creation process.

Usage

The following would apply to all forms:

add_filter( 'gform_advancedpostcreation_post', 'your_function_name', 10, 4 );

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

add_filter( 'gform_advancedpostcreation_post_1', 'your_function_name', 10, 4 );

Parameters

$post boolThe post object to be created.

Array
(
[post_status] => publish
[post_type] => post
[post_title] => testing
[comment_status] => closed
[ping_status] => closed
[ID] => 328
[post_content] => test,test, test, test,
[post_excerpt] => Excerpt Test
[post_author] => 1
[post_date_gmt] => 2019-04-30 20:40:00
)

$feed Feed ObjectThe current feed object.$entry Entry ObjectThe current entry object.$form Form ObjectThe current form object.

Examples

Change the post content

add_filter( 'gform_advancedpostcreation_post', 'change_post', 10, 4 );
function change_post( $post, $feed, $entry, $form){
$post['post_content'] = 'This is a test';
return $post;
}

Change the post slug

This example uses merge tags to change the post slug which is taken from the post_name property. This time we have limited the scope of the snippet to form id 1 by adding the form id to the filter name.

add_filter( 'gform_advancedpostcreation_post_1', function ( $post, $feed, $entry, $form ) {
$slug = '{first name:1.3} {last name:1.6} {date:2:year}-{date:2:month}';
$post['post_name'] = sanitize_title( GFCommon::replace_variables( $slug, $form, $entry, false, false, false, 'text' ) );
return $post;
}, 10, 4 );

Change the post excerpt

This examples uses a specific paragraph field to be written to the post excerpt. Be sure to change your code to match the field id which you are using for inputting the excerpt.

add_filter( 'gform_advancedpostcreation_post', 'change_post_excerpt', 10, 4 );
function change_post_excerpt( $post, $feed, $entry, $form){
$post['post_excerpt'] = rgar( $entry, 6 ); // Field 6 is the Excerpt
return $post;
}

Placement

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

Since

This filter was added in the Gravity Forms Advanced Post Creation add-on version 1.0.

Source Code

This filter is located in GF_Advanced_Post_Creation::create_post() in class-gf-advancedpostcreation.php.

gform_advancedpostcreation_pre_update_post

gform_advancedpostcreation_pre_update_post

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description

Allow custom actions to be performed before the post is updated.

Usage

The following would apply to all forms:

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

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 );

Parameters

$post array The post to be updated. Array returned is the WP get_post function.$feed Feed ObjectThe feed being processed.$entry Entry Object The entry linked to the post.

Examples

add_action( 'gform_advancedpostcreation_pre_update_post', 'pre_update_your_post', 10, 3 );
function pre_update_your_post ($post, $feed, $entry) {
// do something
}

Placement

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

Since

This filter was added in Gravity Forms Advanced Post Creation add-on version 1.0

Source Code

This filter is located in GF_Advanced_Post_Creation:update() in class-post-update-handler.php

gform_advancedpostcreation_term_separator

gform_advancedpostcreation_term_separator

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
Filters the separator character used when separating term names.
Usage
add_filter( 'gform_advancedpostcreation_term_separator', 'your_function_name', 10, 1 );

Parameters

$separator string
The separator to be filtered.

Examples
add_filter( 'gform_advancedpostcreation_term_separator', 'set_separator', 10, 1 );
function set_separator( $separator ){
return '|';
}

Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in the Gravity Forms Advanced Post Creation version 1.0-beta-2.5.
Source Code
This filter is located in GF_Advanced_Post_Creation::get_mapped_taxonomies() in gravityformsadvancedpostcreation/class-gf-advancedpostcreation.php.

gform_advancedpostcreation_update_post_data

gform_advancedpostcreation_update_post_data

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description

Allows modifying the post data before updating it.

Usage

The following would apply 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 );

Parameters

$post arrayThe post array being updated. Array returned is the WP get_post function.$feed Feed ObjectThe feed being processed.$entry Entry ObjectThe entry linked to the post.

Examples

add_filter( 'gform_advancedpostcreation_update_post_data', 'your_update_post_data', 10, 3 );
function your_update_post_data ($post, $feed, $entry) {
// do something
}

Placement

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

Since

This filter was added in the Gravity Forms Advanced Post Creation add-on version 1.0.

Source Code

This filter is located in GF_AdvancedPost_Creation::update() in class-post-update-handler.php

gform_after_check_update

gform_after_check_update

DescriptionUsageParametersExamplesSource Code

Description
Runs a function after Gravity Forms has checked for an update.
Usage
add_action( 'gform_after_check_update', 'my_function', 10, 0 );

Parameters
There are not any parameters for this action.

Examples
function my_function() {
echo 'Update was checked';
}
add_action( 'gform_after_check_update', 'my_function', 10, 0 );

Source Code
This action hook is located in update.php.

gform_after_create_post

gform_after_create_post

DescriptionUsageParametersExamples1. Update the post2. Convert date to the format expected by an ACF datepicker field type3. Update a post custom field with serialized GF checkboxesPlacementSource CodeSince

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 Form Object
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' ) . "

" . rgar( $entry, '13' ) . "
";

//updating post
wp_update_post( $post );
}

2. Convert date to the format expected by an ACF datepicker field type
The example below would take the date saved for a Gravity Forms field with id 30, convert it to the format expected by the ACF datepicker field type, and save it to the custom field meta key acf_date
Make sure to update the field id, the custom field meta key, and the form id number to make it work. Please read the snippet comments.
// Change 12 below to your form id number.
add_action( 'gform_after_create_post_12', 'gf_date_to_acf', 10, 3 );
function gf_date_to_acf( $post_id, $entry, $form ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
// Date as saved by GF. Change 30 to your date field id number.
$gf_date = rgar( $entry, '30' );
// Date changed to format expected by ACF.
$acf_date = date( 'Ymd', strtotime( $gf_date ) );
GFCommon::log_debug( __METHOD__ . '(): Date for ACF: ' . $acf_date );
// Save converted date to the acf_date meta key. Change it to your custom field meta key.
update_post_meta( $post_id, 'acf_date', $acf_date );
}

3. Update a post custom field with serialized GF checkboxes
This is useful for plugins like Advanced Custom Fields (ACF), Types and Pods where the values of the selections are stored in a serialized array. The scope of this example is limited to form id 1 and field id 18, you need to update these values to apply to your own form and field.
// Change 1 in gform_after_create_post_1 to your form id number.
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. Change this value to your field id number.
$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', $value );
}

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.

gform_after_delete_field

gform_after_delete_field

DescriptionUsageParametersExamplesSource Code

Description
Use this action hook to perform actions right after a field is deleted from a form.
Usage
add_action( 'gform_after_delete_field', 'do_cleanup', 10, 2 );

Parameters

$form_id integer
ID of current form.

$field_id integer
ID of deleted field.

Examples
This example adds a log file entry when a field is deleted.
add_action( 'gform_after_delete_field', 'log_deleted_field', 10, 2 );
function log_deleted_field( $form_id, $field_id ) {
$log_file = ABSPATH . '/gf_deleted_fields.log';
$f = fopen( $log_file, 'a' );
$user = wp_get_current_user();
fwrite( $f, date( 'c' ) . " - Field deleted by {$user->user_login}. Form ID: {$form_id}. Field ID: {$field_id} n" );
fclose( $f );
}

Source Code
This action hook is located in GFFormsModel::delete_field() in form_model.php.

gform_activecampaign_contact_pre_sync

gform_activecampaign_contact_pre_sync

DescriptionUsageParametersExamplesPlacementSource CodeSince

Description
The gform_activecampaign_contact_pre_sync filter can be used to override the contact properties before the contact_sync request is sent to the API.
Usage
The filter which would run for all ActiveCampaign feeds can be used like so:
add_filter( 'gform_activecampaign_contact_pre_sync', 'your_function_name', 10, 4 );

You can limit the scope of the filter to a single form by appending the form id on the end of the hook name like so:
add_filter( 'gform_activecampaign_contact_pre_sync_5', 'your_function_name', 10, 4 );

Parameters

$contact array
The contact properties. See the ActiveCampaign API documentation for the full list of accepted properties.

$entry Entry Object
The entry currently being processed.

$form Form Object
The form object the current entry was created from.

$feed Feed Object
The feed which is currently being processed.

Examples
This example shows how you can add the ip4 property to the array.
add_filter( 'gform_activecampaign_contact_pre_sync', function( $contact, $entry, $form, $feed ) {

$contact['ip4'] = rgar( $entry, 'ip' );

return $contact;
}, 10, 4 );

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
$contact = apply_filters( 'gform_activecampaign_contact_pre_sync', $contact, $entry, $form, $feed );
$contact = apply_filters( 'gform_activecampaign_contact_pre_sync_' . $form['id'], $contact, $entry, $form, $feed );

This filter is located in GFActiveCampaign::process_feed() in class-gf-activecampaign.php.
Since
This filter was added in ActiveCampaign 1.3.5.

gform_activecampaign_enable_tag_mapping

gform_activecampaign_enable_tag_mapping

DescriptionUsageParametersPlacementSource Code

Description
This filter is used to enable the display of the tags field in the Map Fields section of the ActiveCampaign feed.

This hook was removed in ActiveCampaign 1.2 when the tags mapping setting was removed and replaced by a tags text input with merge tag support.

Usage
add_filter( 'gform_activecampaign_enable_tag_mapping', '__return_true' );

Parameters
This hook has no parameters.
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in class-gf-activecampaign.php.

gform_{$SHORT_SLUG}_field_value

gform_{$SHORT_SLUG}_field_value

DescriptionShort Slug ValuesUsageParametersExamples1. ActiveCampaign – Use Choice Text Instead of Value2. ActiveCampaign – Replace Commas with Pipes3. Emma – Format Checkbox Field4. Help Scout – Change Value of Specific Field5. Zoho CRM – Format Date Field6. Zoho CRM – Format Checkbox FieldPlacementSinceSource Code

Description
This filter can be used to modify a value before it is sent to a third-party by one of the Add-On Framework based add-ons. If you want to filter the value for any add-on you can use gform_addon_field_value.
Short Slug Values
The Gravity Forms Add-On Slugs article lists the available short slugs to use with this hook:
The following add-ons listed in the slug article do not use the hook:

Gravity Forms CLI Add-On
Gravity Forms Debug Add-On
Gravity Forms Gutenberg Add-On

The Zapier Add-On implements its own version of the hook:

gform_zapier_field_value

Usage
The base filter which would run for all forms and all fields would be used like so:
1add_filter( 'gform_helpscout_field_value', 'your_function_name', 10, 4 );
To target a specific form append the form id to the hook name. (format: gform_{$SHORT_SLUG}_field_value_FORMID)
1add_filter( 'gform_helpscout_field_value_10', 'your_function_name', 10, 4 );
To target a specific field append both the form id and the field id to the hook name. (format: gform_{$SHORT_SLUG}_field_value_FORMID_FIELDID)
1add_filter( 'gform_helpscout_field_value_10_3', 'your_function_name', 10, 4 );

Parameters

$value string
The value to be modified.

$form Form Object
The form currently being processed.

$entry Entry Object
The entry currently being processed.

$field_id string
The ID of the field currently being processed.

Examples
1. ActiveCampaign – Use Choice Text Instead of Value
This example shows how you can replace the value of a choice based survey field with the choice text.
1234567891011add_filter( 'gform_activecampaign_field_value', 'gf_get_choice_text', 10, 4 );function gf_get_choice_text( $value, $form, $entry, $field_id ) {    gf_activecampaign()->log_debug( __METHOD__ . '(): running.' );    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && $field->type == 'survey' ) {        $value = $field->get_value_export( $entry, $field_id, true );        gf_activecampaign()->log_debug( __METHOD__ . '(): Value: ' . $value );    }    return $value;}
2. ActiveCampaign – Replace Commas with Pipes
This example shows how you can replace the commas used to separate checkbox or multi select choices with pipe characters.
123456789101112add_filter( 'gform_activecampaign_field_value', 'gf_replace_commas_with_pipes', 10, 4 );function gf_replace_commas_with_pipes( $value, $form, $entry, $field_id ) {    gf_activecampaign()->log_debug( __METHOD__ . '(): running.' );    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && ( $field->type == 'checkbox' || $field->type == 'multiselect' ) ) {        $value = str_replace( ', ', '||', $value );        gf_activecampaign()->log_debug( __METHOD__ . '(): Value: ' . $value );    }     return $value;}
3. Emma – Format Checkbox Field
This example shows how you can reformat the checkbox field value to be passed as an array instead of a string.
123456789add_filter( 'gform_emma_field_value', function ( $value, $form, $entry, $field_id ) {    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && $field->get_input_type() === 'checkbox' ) {        $value = explode( ', ', $value );    }     return $value;}, 10, 4 );
4. Help Scout – Change Value of Specific Field
This example shows how you can change the value of field 3 on form 10 before it is passed to Help Scout.
1234add_filter( 'gform_helpscout_field_value_10_3', function ( $value, $form, $entry, $field_id ) {     return 'your new value';}, 10, 4 );
5. Zoho CRM – Format Date Field
This example shows how you can reformat the entry date from yyyy-mm-dd to the format configured on the field.
123456789add_filter( 'gform_zohocrm_field_value', function ( $value, $form, $entry, $field_id ) {    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && $field->type == 'date' ) {        $value = GFCommon::date_display( $value, $field->dateFormat );    }     return $value;}, 10, 4 );
6. Zoho CRM – Format Checkbox Field
This example shows how you can reformat the checkbox field value to pass true or false instead of the choice. This snippet is not needed if you』re using version 1.8 of the add-on or newer.
1234567891011add_filter( 'gform_zohocrm_field_value', function ( $value, $form, $entry, $field_id ) {    gf_zohocrm()->log_debug( __METHOD__ . '(): Running...' );    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && $field->get_input_type() === 'checkbox' ) {        gf_zohocrm()->log_debug( __METHOD__ . '(): Checkbox value to true or false.' );        $value = $value ? 'true' : 'false';    }     return $value;}, 10, 4 );
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms 1.9.10.11.
Source Code
1234gf_apply_filters( "gform_{$slug}_field_value", array(    $form['id'],    $field_id), $field_value, $form, $entry, $field_id );
This filter is located in GFAddOn::maybe_override_field_value() in includes/addon/class-gf-addon.php.