[FORMINATOR PRO] Email Notification Routing

Hi there,

I would like to request the following feature:
-Routing - Allows notification to be sent to different email addresses depending on values selected in the form
LIKE this https://docs.gravityforms.com/email-routing-gravity-forms-confirmations/

  • F404
    • Flash Drive

    Hello
    1. Then in previous answer why i get this answer :
    Sat Feb 16 2019

    I can see this task having a "high" priority so this should be included in a near-future update.

    2. Current version version is 1.7.0.1
    1.7.5 to 1.7.6. this update will be 2 years later :smiley:

    • Nastia
      • Support Rock Star

      Hello F404

      Hope all is well!

      I am afraid we do not share an exact ETA, to prevent disappointment if a deadline is missed (which in plugin development quite a frequent occurrence!). Two years is a long time, I believe the feature development will not take this long :wink:

      The feature is under development, once it will be completed and will pass all the testing it will be released. Our goal is to release a bug-free plugin :smiley:

      We really appreciate your patience in here!

      Kind regards,
      Nastia

  • Prathamesh Palve
    • Staff

    Hey F404,

    I went ahead and made a few tests after which I found that you can make is possible if you use radio field but I'm afraid it would not be currently possible for a selection field. Here is how you can make it possible to do it with the radio field.

    Step 1: Create a Radio Field. In each radio option, enter the email id you which to have the email if that option is selected as shown below:
    [image pos="0"]
    Also, Create an Email Address section in the same form to accept user email.

    Step2: I have seen that the functions would not work properly if you create things in the Admin Confirmation email. We have already tasked that and we would be worked out soon. For now, we would be using Confirmation Emails Section for this purpose. That is in the Email Notification section, we would use the Confirmation email to send emails to the Admins and the user too as of now. Here is how we will be doing it:

    Here the Radio option will send emails to the specific emails and the email option will send an exact copy of the same to the user too(Highlighted in RED BOX). If you do not want the user to receive an email you can just add the Radio option.

    I'm aware this way we would not be able to send a different custom email to the user filling the form. As I said we have tasked this to be enabled in the Admin Email so both the functionalities can be achieved. This is just a temporary solution which should work for you. We will soon come up with the functionality to enable the same in the Admin Email.

    If you have any doubts or need any help, feel free to reply in the threads here and we would be happy to help you with it.

    Thanks,
    Prathamesh

  • Prathamesh Palve
    • Staff

    Hello F404,

    To make this possible, please navigate to the Forminator-> Forms-> Edit form-> Email Notifications-> Confirmation Email-> Message Body-> Add Form Data. Add the fields individually for example: `{radio-1}
    {email-1}`

    If you use the all fields form data option( {all_fields} ), it would not be possible with it. Can you try this on your end once and let me know if that works for you? I am looking forward to hearing from you.

    Thanks,
    Prathamesh

  • Panos
    • SLS

    Hi F404 !

    You can try adding the following snippet in a mu-plugin :

    add_filter( 'forminator_get_formatted_form_entry', function( $html, $custom_form, $data, $entry, $ignored_field_types ){
    
    	//$field_slugs = array( 'select-1', 'select-2' );
    
    	$ignored_field_types = Forminator_Form_Entry_Model::ignored_fields();
    	$form_fields         = $custom_form->get_fields();
    	if ( is_null( $form_fields ) ) {
    		$form_fields = array();
    	}
    	$html = '<br/><ol>';
    	foreach ( $form_fields as $form_field ) {
    
    		//if ( in_array( $form_field->slug, $field_slugs ) ) {
    		if ( 'select' == $form_field->raw['type'] ){
    
    			$value = render_entry( $entry, $form_field->slug );
    
    			if ( empty( $value ) ) {
    				$value = isset( $_POST[ $form_field->slug ] ) ? $_POST[ $form_field->slug ] : '';
    
    			}
    
    			if( ! empty( $value ) ) {
    
    				$options = $form_field->raw[ 'options' ];
    
    				foreach ( $options as $key => $option ) {
    					if ( isset( $option['label'] ) && isset( $option['value'] ) && $value == $option['value'] ) {
    						$html  .= '<li>';
    						$label = $form_field->get_label_for_entry();
    						$option_label = $option['label'];
    
    						if ( ! empty( $label ) ) {
    							$html .= "<b>{$label} : {$option_label}: <br />";
    						}
    						$html .= "Value : {$value} <br />";
    						$html .= '</li>';
    
    					}
    				}
    
    				continue;
    			}
    
    		}
    
    		// @var  Forminator_Form_Field_Model $form_field
    		$field_type = $form_field->__get( 'type' );
    		if ( 'section' === $field_type ) {
    			$value = $form_field->__get( 'section_title' );
    			if( ! empty( $value ) ) {
    				$html .= '</ol>';
    				$html .= '<h4><b>' . $value . '</b></h4>';
    				$html .= '<ol>';
    			}
    		} elseif ( 'html' === $field_type ) {
    			$label   = $form_field->get_label_for_entry();
    			$value   = $form_field->__get( 'variations' );
    			$content = forminator_replace_variables( $value, $custom_form->id, $data['current_url'] );
    			$html    .= '</ol>';
    			$html    .= '<h4><b>' . $label . '</b></h4>';
    			$html    .= $content;
    			$html    .= '<ol>';
    
    		} else {
    			if ( in_array( $field_type, $ignored_field_types, true ) ) {
    				continue;
    			}
    			$value = render_entry( $entry, $form_field->slug );
    			if( ! empty( $value ) ) {
    				$html  .= '<li>';
    				$label = $form_field->get_label_for_entry();
    
    				if ( ! empty( $label ) ) {
    					$html .= '<b>' . $label . '</b><br/>';
    				}
    				$html .= $value . '<br/>';
    				$html .= '</li>';
    			}
    		}
    	}
    	$html .= '</ol><br/>';
    
    	return $html;
    }, 20, 5 );

    That should check all select fields in the form. If you need to specify then you need to un-comment lines:
    //$field_slugs = array( 'select-1', 'select-2' );
    and
    //if ( in_array( $form_field->slug, $field_slugs ) ) {
    and comment out line:
    if ( 'select' == $form_field->raw['type'] ){
    You will also need to set the proper fields in the first line that was un-comented.

    Hope this helps!

    Kind regards!

  • Prathamesh Palve
    • Staff

    Hello F404,

    You can try to add the following code by replacing the above code:

    add_filter( 'forminator_get_formatted_form_entry', function( $html, $custom_form, $data, $entry, $ignored_field_types ){
            if(  ! in_array( $custom_form->id, array( 1,2,3 ) ) return $html;
        //$field_slugs = array( 'select-1', 'select-2' );
    
        $ignored_field_types = Forminator_Form_Entry_Model::ignored_fields();
        $form_fields         = $custom_form->get_fields();
        if ( is_null( $form_fields ) ) {
            $form_fields = array();
        }
        $html = '
    <ol>';
        foreach ( $form_fields as $form_field ) {
    
            //if ( in_array( $form_field->slug, $field_slugs ) ) {
            if ( 'select' == $form_field->raw['type'] ){
    
                $value = render_entry( $entry, $form_field->slug );
    
                if ( empty( $value ) ) {
                    $value = isset( $_POST[ $form_field->slug ] ) ? $_POST[ $form_field->slug ] : '';
    
                }
    
                if( ! empty( $value ) ) {
    
                    $options = $form_field->raw[ 'options' ];
    
                    foreach ( $options as $key => $option ) {
                        if ( isset( $option['label'] ) && isset( $option['value'] ) && $value == $option['value'] ) {
                            $html  .= '
    <li>';
                            $label = $form_field->get_label_for_entry();
                            $option_label = $option['label'];
    
                            if ( ! empty( $label ) ) {
                                $html .= "<b>{$label} : {$option_label}: ";
                            }
                            $html .= "Value : {$value} ";
                            $html .= '</li>
    ';
    
                        }
                    }
    
                    continue;
                }
    
            }
    
            // @var  Forminator_Form_Field_Model $form_field
            $field_type = $form_field->__get( 'type' );
            if ( 'section' === $field_type ) {
                $value = $form_field->__get( 'section_title' );
                if( ! empty( $value ) ) {
                    $html .= '</ol>
    ';
                    $html .= '<h4><b>' . $value . '</b></h4>';
                    $html .= '
    <ol>';
                }
            } elseif ( 'html' === $field_type ) {
                $label   = $form_field->get_label_for_entry();
                $value   = $form_field->__get( 'variations' );
                $content = forminator_replace_variables( $value, $custom_form->id, $data['current_url'] );
                $html    .= '</ol>
    ';
                $html    .= '<h4><b>' . $label . '</b></h4>';
                $html    .= $content;
                $html    .= '
    <ol>';
    
            } else {
                if ( in_array( $field_type, $ignored_field_types, true ) ) {
                    continue;
                }
                $value = render_entry( $entry, $form_field->slug );
                if( ! empty( $value ) ) {
                    $html  .= '
    <li>';
                    $label = $form_field->get_label_for_entry();
    
                    if ( ! empty( $label ) ) {
                        $html .= '<b>' . $label . '</b>';
                    }
                    $html .= $value . '';
                    $html .= '</li>
    ';
                }
            }
        }
        $html .= '</ol>
    ';
    
        return $html;
    }, 20, 5 );

    I have just added the following additional code before the code suggested by Panos:

    add_filter( 'forminator_get_formatted_form_entry', function( $html, $custom_form, $data, $entry, $ignored_field_types ){
             if(  ! in_array( $custom_form->id, array( 1,2,3 ) ) return $html;

    Hope this helps!

    Regards,
    Prathamesh

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.