• Resolved thankssforhelp

    (@thankssforhelp)


    Hi there,

    I would be very grateful if you can help me with the following issue:

    I am using the following php snippet in mu-plugins, which works great. However, I would like to use this snippet for more than just one form. So I was trying to add further form-id’s but couldn’t really get it.

    <?php
    add_filter( 'forminator_form_get_admin_email_recipients', 'wpmudev_set_multiple_mail_recipients', 10, 5 );
    function wpmudev_set_multiple_mail_recipients( $email, $notification, $prepared_data, $module, $entry ) {
    	if( $prepared_data['form_id'] != 9393){
    		return $email;
    	}
    
    	if( $notification['recipients'] == '{multiple-mails}' ) {
    		$my_post = get_post(1234);
    		$mails = str_replace( '"', '', str_replace( ']', '', str_replace( '[' , '', $my_post->post_content)));
    		$mails = array_filter( explode( ",", $mails ), function($value) {
    			return ( $value !== NULL && $value !== FALSE && $value !=='' );
    		});
    		if( $mails ){
    			$email = $mails;
    		}
    	}
    
    	return $email;
    }

    I tried to add }elseif( $prepared_data['form_id'] != 8489){ to have another condition with another form-Id but it didn’t work.

    So is there a way to add further form-Id’s here?

    Thank you very much in advance and kind regards

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How add several Form-ID’s in php snippet’ is closed to new replies.