gform_hubspot_form_object_pre_save_feed

Description

Allows the HubSpot form object to be filtered before saving the feed.

Usage

The following would apply to all forms:

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

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

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

Parameters

Examples

Add submitText

add_filter( 'gform_hubspot_form_object_pre_save_feed', 'change_hubspot_feed', 10, 3 );
function change_hubspot_feed( $hs_form, $feed_meta, $form ){
    $hs_form['submitText'] = 'Submit the Form';
    return $hs_form;
}

Add ignoreCurrentValues & disableCookieSubmission

add_filter( 'gform_hubspot_form_object_pre_save_feed', function ( $hs_form, $feed_meta, $form ) {
	// Always create contact for new email address.
	$hs_form['ignoreCurrentValues'] = true;

	// Pre-populate contact fields with known values.
	$hs_form['metaData'] = array(
		array(
			'name'  => 'disableCookieSubmission',
			'value' => true,
		),
	);

	return $hs_form;
}, 10, 3 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in HubSpot version 1.0.

Source Code

This filter is located in GF_HubSpot::generate_hubspot_form_object() in class-gf-hubspot.php.