This filter is run when WP Fusion is processing a form submission from one of our supported form plugins.

It is triggered after the contact record has been created / updated in the CRM, but before any tags have been applied. It can be used to modify the tags that will be applied as part of the form submission.

To use the code examples below, add them to your active theme’s functions.php file.

#Alternate filters

For more precise targeting there are two alternate filters with the same arguments:

  • wpf_{integration slug}_apply_tags : Where {integration_slug} is the name of the form integration, for example wpf_gform_apply_tags
  • wpf_{integration slug}_apply_tags_{form_id} : Where {form_id} is the ID of the submitted form, for example wpf_ninja_forms_apply_tags_1


  • $apply_tags (array): This is an array of tags that will be applied to the person who submitted the form
  • $user_id (int): The user who submitted the form, 0 if a guest
  • $contact_id (string): The ID of the contact record created / updated by the form submission
  • $form_id (int): The ID of the submitted form


This example checks to see if the person submitting the form came to the site via an AffiliateWP affiliate link, and is being tracked with the affwp_refcookie. If so, the tag Affiliate Tag is applied.

function merge_affiliate_tags( $apply_tags, $user_id, $contact_id, $form_id ) {

	if ( isset( $_COOKIE['affwp_ref'] ) ) {
		$apply_tags[] = 'Affiliate Tag';

	return $apply_tags;


add_filter( 'wpf_forms_apply_tags', 'merge_affiliate_tags', 10, 4 );

#Use “Round Robin” assignment for leads

This example randomly assigns each lead a tag of either Tag A, Tag B or Tag C. This is similar to the “Round Robin” owner assignment in sales CRMs like Infusionsoft, and can be used to randomly assign leads to a sales rep.

function apply_round_robin_tags( $apply_tags ) {

	// To properly randomize the tags we'll do it based on the current time

	$time = date( 's' );

	// $time will be 00 to 59

	if ( $time < 20 ) { $apply_tags[] = 'Tag A'; } elseif ( $time >= 20 && $time < 40 ) {
		$apply_tags[] = 'Tag B';
	} elseif ( $time < 60 ) {
		$apply_tags[] = 'Tag C';

	return $apply_tags;


add_filter( 'wpf_forms_apply_tags', 'apply_round_robin_tags' );

Was this helpful?