Adding Contact Properties for HubSpot Addon

Overview

Would you like to include additional properties in the custom field section when customizing the HubSpot addon? Our HubSpot addon lets you include additional form fields that’ll map to fields in your HubSpot account. However, you can extend this feature to include more field properties not currently supported by the core addon.

This guide will cover the steps to add the snippet to your WordPress site.


Adding the Snippet

To start, you’ll need to add the snippet below to your site. If you’re not sure how or where to add snippets, please review this helpful documentation.

/**
  * Filter whether a specific HubSpot property should be allowed.
  *
  * @link https://wpforms.com/developers/adding-contact-properties-for-hubspot-addon/
  * @since {VERSION}
  *
  * @param bool   $allowed  Whether the property is allowed. Default false.
  * @param mixed  $property The HubSpot property being checked.
  *
  * @return bool True to allow the property, false to disallow.
*/

function wpf_hubspot_add_property( $allow, array $property ) {

	return $property['groupName'] === 'conversioninformation' ? true : $allow;

}

add_filter( 'wpforms_hubspot_api_allow_property', 'wpf_hubspot_add_property', 10, 2 );

In the code above, we’re updating HubSpot’s API to include the conversioninformation details as an option when setting custom fields with the HubSpot addon.

Viewing New Properties

Once the snippet is added, the new property will be added to the list of available fields when customizing custom fields in the HubSpot integration page.

To confirm your settings, create a new form or edit an existing one to access the form builder. In the form builder, navigate to Marketing » HubSpot and select the Custom Field Name dropdown.

HubSpot addon custom field section

You’ll see all the fields under the property you added listed in the dropdown.

Conversion information section

To learn more about the HubSpot addon, be sure to check our detailed guide on installing and using the HubSpot addon in WPForms.

Frequently Asked Questions

Below, we’ve answered some of the top questions about extending contact properties when using the HubSpot addon with WPForms.

Can I allow multiple properties?

You can modify the snippet to include additional properties. Here’s the snippet to achieve that:

function wpf_hubspot_add_multiple_properties( $allow, array $property ) {

	return in_array( $property['groupName'], [ 'conversioninformation', 'analyticsinformation' ], true ) ? true : $allow;

}

add_filter('wpforms_hubspot_api_allow_property', 'wpf_hubspot_add_multiple_properties', 10, 2);

In the snippet above, we are updating the API to include both the conversioninformation and analyticsinformation properties.

Can I include all contact properties from HubSpot?

Yes, you can include all additional contact properties from your HubSpot account to WPForms. To do so, simply add the snippet below to your site:

add_filter( 'wpforms_hubspot_api_allow_property', '__return_true' );

That’s it! You’ve now learned how to customize the HubSpot addon to include additional contact properties.

Next, would you like to access the URL for files uploaded through the File Upload field? Be sure to check our tutorial to learn how.

Filter Reference: wpforms_hubspot_api_allow_property