Fires on form submit to load the URL needed for the redirect.


(string) URL for the redirect.
(int) Form ID.
(array) Processed form settings/data, prepared to be used later.
(array) Sanitized field data.
(int) Entry id.



More Information

The wpforms_process_redirect_url filter that will be used to for the redirect once the form submits.


In this example, we’re going to set up the form for a redirect in the form builder settings, then based on a specific question on the form, redirect the user to different URLs based on the answer.

 * Redirect URL.
 * @link
 * @param string     $url       URL to redirect to.
 * @param int        $form_id   The form ID.
 * @param array      $form_data Processed form settings/data.
 * @param array      $fields    Sanitized fields data.
 * @param int        $entry_id  Entry id.
 * @return string
function wpf_dev_process_redirect_url( $url, $form_id, $fields, $form_data, $entry_id ) {
// Only run on my form with ID = 879.
    if ( absint( $form_data['id'] ) !== 879 ) {
        return $fields;
	// Assign the checkbox field that shows the room number to a variable
	$room_number = $fields[4]['value']; 
	if ($room_number === "Room A") {
		// Redirect to page with Room A information
		$url = '';
	    elseif ($room_number === "Room B") {
			// Redirect to page with Room B information
			$url = '';
		    elseif ($room_number === "Room C") {
			// Redirect to page with Room C information	
			$url = '';
	    else {
			// Keep the current redirect URL that is set in the form builder settings
			$url = $url;
    return $url;
add_filter( 'wpforms_process_redirect_url', 'wpf_dev_process_redirect_url', 10, 5 );

If the user selects to reserve Room A, the form will ignore the URL from the form builder’s redirect settings on the Confirmations tab and instead redirect to a URL containing information about Room A. The loop continues through the options listed for each room with a fallback in the final else and keep the original URL from the form builder settings.

Snippet Reference: How to Preserve the Query Strings in the URL on Form Submit