Title: Problem with routing
Last modified: February 23, 2023

---

# Problem with routing

 *  Resolved [mitys](https://wordpress.org/support/users/mitys/)
 * (@mitys)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/problem-with-routing/)
 * Hello, I have routing conditions on my forms but some of the conditions are not
   working and the form is sending to the default email address.
 * [https://ibb.co/z4nztSn](https://ibb.co/z4nztSn)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [Nebu John – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport14/)
 * (@wpmudevsupport14)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/problem-with-routing/#post-16501453)
 * Hi [@mitys](https://wordpress.org/support/users/mitys/),
 * Sorry to know that you are experiencing an issue.
 * Could you please export the form and share using pastebin.com or Google Drive
   so that we can check things further? Please find how to export a Forminator form
   in our documentation here: [https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export](https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export)
 * We look forward to hearing back from you.
 * Kind Regards,
   Nebu John
 *  Thread Starter [mitys](https://wordpress.org/support/users/mitys/)
 * (@mitys)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/problem-with-routing/#post-16501755)
 * Hello, here is the link of the google drive:
 * [https://docs.google.com/document/d/1kiuiSgwIYVMsNqm3V7L8DS6Kz6GJEgEq9eRatF1LJ0Y/edit?usp=sharing](https://docs.google.com/document/d/1kiuiSgwIYVMsNqm3V7L8DS6Kz6GJEgEq9eRatF1LJ0Y/edit?usp=sharing)
 * When sending a form with the value J2K in the text-3 field, the sending is redirected
   to the default email.
 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/problem-with-routing/#post-16505758)
 * Hi [@mitys](https://wordpress.org/support/users/mitys/)
 * Thank you for the form.
   I can see this has massive conditionals and even freezes
   my screen when I switch from default to routing.I would like to check with our
   developers if there is any better way to set this and decrease the resource usage
   by the plugin to avoid some failures.Before that, let me ask if those conditionals
   following any rule example always have X number of characters and prefix goes
   to X email.In case you would like to share the rules using our email [wpsupport@incsub.com](https://wordpress.org/support/topic/problem-with-routing/wpsupport@incsub.com?output_format=md)
   with this subject ATTN: WPMU DEV support – wp.org Best RegardsPatrick Freitas
 *  Plugin Support [Amin – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support2/)
 * (@wpmudev-support2)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/problem-with-routing/#post-16532436)
 * Hello [@mitys](https://wordpress.org/support/users/mitys/) ,
 * Please try the following code snippet as a MU plugin ([https://premium.wpmudev.org/docs/getting-started/download-wpmu-dev-plugins-themes/#installing-mu-plugins](https://premium.wpmudev.org/docs/getting-started/download-wpmu-dev-plugins-themes/#installing-mu-plugins))
 *     ```
       <?php
       add_filter( 'forminator_form_get_admin_email_recipients', 'wpmudev_csv_email_recipients', 10, 5 );
       function wpmudev_csv_email_recipients( $email, $notification, $prepared_data, $module, $entry ) {
       	if ( $module->id != 4620 ) {
       		return $email;
       	}
   
       	$email 		= array();
       	$recipients = array();
       	$i			= 0;
       	$nf_routing = array();
       	$file       = fopen( 'https://docs.google.com/spreadsheets/d/1ov51zLpOiPqjpEV1D_GOqSNI6WK7x-_d/export?format=csv&id=1ov51zLpOiPqjpEV1D_GOqSNI6WK7x-_d', 'r' );
   
       	while ( ( $line = fgetcsv( $file, 1000, "," ) ) !== false ) {
       		if ( $i > 0 ) {
       			$nf_routing[] = array( 'email' => $line[0], 'element_id' => $line[1], 'rule' => $line[2], 'value' => $line[3] );
       		}
       		$i++;
       	}
   
       	if ( ! empty( $nf_routing ) ) {
       		foreach ( $nf_routing as $routing ) {
       			if ( Forminator_Field::is_condition_matched( $routing ) ) {
       				if ( false !== strpos( $routing['email'], ',' ) ) {
       					$recipients = array_merge( array_map( 'trim', explode( ',', $routing['email'] ) ), $recipients );
       				} else {
       					$recipients[] = trim( $routing['email'] );
       				}
       			}
       		}
       	}
   
       	if ( ! empty( $recipients ) ) {
       		foreach ( $recipients as $key => $recipient ) {
       			$mail_sender = new Forminator_CForm_Front_Mail();
       			$recipient = $mail_sender->get_recipient( $recipient, $module, $entry, array() );
       			if ( false !== strpos( $recipient, ',' ) ) {
       				$emails = array_map( 'trim', explode( ',', $recipient ) );
       				if ( ! empty( $emails ) ) {
       					foreach ( $emails as $email_key => $email_recipient ) {
       						if ( is_email( $email_recipient ) ) {
       							$email[] = $email_recipient;
       						}
       					}
       				}
       			} else {
       				if ( is_email( $recipient ) ) {
       					$email[] = $recipient;
       				}
       			}
       		}
       	}
   
       	return $email;
       }
       ```
   
 * In the code 4620 should be changed to your form’s ID. The code will read the 
   routing conditions from the google doc(shared in this task) and set the recipient
   if the rule matches.
 * kind regards,
    Kasia
 *  Plugin Support [Amin – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support2/)
 * (@wpmudev-support2)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/problem-with-routing/#post-16572888)
 * Hello [@mitys](https://wordpress.org/support/users/mitys/) ,
 * We haven’t heard from you for over a week now, so it looks like you no longer
   need our assistance.
 * Feel free to re-open this ticket if needed.
 * Kind regards
    Kasia

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Problem with routing’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [Amin – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support2/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/problem-with-routing/#post-16572888)
 * Status: resolved