Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @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

    We look forward to hearing back from you.

    Kind Regards,
    Nebu John

    Thread Starter mitys

    (@mitys)

    Hello, here is the link of the google drive:

    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

    (@wpmudevsupport12)

    Hi @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 [email protected] with this subject ATTN: WPMU DEV support – wp.org

    Best Regards
    Patrick Freitas

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @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 )

    
    <?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

    (@wpmudev-support2)

    Hello @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.