• Resolved squeebo

    (@squeebo)


    I’m looking for a way to randomly or sequentially distribute each of the form submission emails to one of a few people on a team. Currently I have form submissions going to one person, but I’d like to split them between two people, and perhaps more in the future.

    Even a forwarding solution outside of WP is fine. I don’t see anything in cpanel that can do it, nor any online service other than some expensive software like Salesforce. It seems like such a simple task that a million people would want to do without having to resort to a whole software package.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @squeebo

    I hope you are doing well.

    We don’t have a native option for that but I pinged our developers to verify if we can find a workaround for you.

    We will keep you posted.
    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @squeebo

    Could you please try

    <?php
    
    add_action( 'plugins_loaded', function() {
    	if ( ! defined( 'FORMINATOR_VERSION' ) ) {
    		return; // Forminator is not installed/enabled.
    	}
    	add_filter( 'forminator_form_get_admin_email_recipients', function(  $email, $notification, $prepared_data, $module, $entry ) {
    		if ( empty( $email ) || ! is_array( $email ) || 1 === count( $email ) ) {
    			return $email;
    		}
    		
    		// >>> SETTINGS [BEGIN]
    		$form_id = 6;      // Target form ID.
    		$random  = false;  // Set to TRUE to use a random approach.
    		// <<< SETTINGS [END]
    
    		if ( $form_id !== $module->id ) {
    			return $email;
    		}
    
    		$count      = count( $email );
    		$rand_email = array( 
    			$email[ rand( 0, $count - 1 ) ] 
    		);
    
    		if ( $random ) {
    			return $rand_email;
    		} 
    
    		$entry_id   = $entry->entry_id;
    		$index      = ( $entry_id % $count ) - 1;
    		$index      = -1 === $index ? ( $count - 1 ) : $index;
    		$next_email = isset( $email[ $index ] ) ? array( $email[ $index ] ) : $rand_email;
    	
    		return $next_email;
    	}, 10, 5 );
    });

    Replace $form_id by the target form and set $random as TRUE to enable the random email selection.

    Example Recipients field:

    https://monosnap.com/file/RMu3uZNFcepBLqt0BqUO6sw44XRsvH

    Let us know the result you got.
    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @squeebo

    Just a small update in the screenshot link https://monosnap.com/file/tqj7pd2osxRKFBKBX9GZCkWDvbv2IJ

    Best Regards
    Patrick Freitas

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @squeebo ,
    
    We haven’t heard from you for several days now, so it looks like you no longer need our assistance.
    
    Feel free to re-open this ticket if needed.
    
    Kind regards
    Kasia

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

The topic ‘randomly route emails?’ is closed to new replies.