wpf_forms_post_submission

#Overview

This action is run when WP Fusion has finished processing a form entry from one of our supported form plugins.

It can be used to perform additional actions with the contact ID that was created in your CRM, for example triggering an event, or updating a note/opportunity.

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

#Parameters

  • $update_data (array): This is an array of data that was synced to the CRM
  • $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

#Examples

#Redirect an Elementor forms submission to an auto-login URL on another site

This example runs when an Elementor form is submitted and overrides the form’s redirect to https://siteb.com/?cid=Xwhere X is the ID of the contact record that was just created or updated by WP Fusion.

This redirect will then start an auto-login session for that contact on https://siteb.com

function wpf_custom_redirect( $update_data, $user_id, $contact_id, $form_id ) {

	if ( wp_doing_ajax() ) {

		$redirect_url = 'https://siteb.com';
		$query_args   = array( 'cid' => $contact_id );

		wp_send_json_success( [
			'message' => 'Success!',
			'data'    => array( 'redirect_url' => add_query_arg( $query_args, $redirect_url ) ),
		] );
	}

}

add_action( 'wpf_forms_post_submission', 'wpf_custom_redirect', 10, 4 );

Was this helpful?