• Resolved kevinqi

    (@kevinqi)


    Hi I hope you guys are doing well. First of all, thanks for your great work, forminator is the most powerful and useful form plugin I ever used.

    Recently I created a form to help the clients self-assessment by using the multi-submission behaviors feature. And it will redirect to different page based on behavior rules after the client submit the form.

    I’d like to know is there any solution to put the result info of the redirection /behavior into the notification email for admin? I checked the merge tags list in the document, but no tags about redirect url there.

    Thanks again

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @kevinqi

    I hope you’re well today!

    You mean including information which of the redirects was used in the e-mail notification?

    If yes, I’m afraid this isn’t possible. Technically speaking:

    – the e-mail notification is sent first and the redirect happens after that
    – at the time of notification sending, code doesn’t know yet which redirect will be used as those conditions are not processed yet.

    So that’s not doable, I’m afraid.

    Kind regards,
    Adam

    Thread Starter kevinqi

    (@kevinqi)

    Hi Adam, thanks so much for your quick response.

    If so, is it possible to show the redirect result in the submissions list? or can forminator hold a log file to record the results?

    Kind regards

    Kevin

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @kevinqi

    It’s not possible out of the box either, I’m afraid.

    But it may actually be possible with a bit of custom code – to modify existing submission to inject that redirect URL into it after submission is already made.

    I need to consult that with our developers so I have already asked them and they’ll see if/what can be done about that.

    We’ll update you here soon with more information (though I’d appreciate some patience).

    Kind regards,
    Adam

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @kevinqi ,

    Please try this code snippet:

    <?php
    
    add_action( 'plugins_loaded', 'wpmudev_forminator_add_redirect_url_to_hidden_field_func', 100 );
    
    function wpmudev_forminator_add_redirect_url_to_hidden_field_func() {
    	if ( defined('FORMINATOR_PRO') && class_exists( 'Forminator' ) ) {
    		class wpmudev_forminator_add_redirect_url_to_hidden_field_func{
    			private $form_id = 6;//enter form_id here
    			private $redirect_url;
    
    			public function __construct() {
                    add_filter( 'forminator_form_submit_response', array( $this, 'get_redirect_url_form_submission' ), 20, 2 );
                    add_filter( 'forminator_form_ajax_submit_response', array( $this, 'get_redirect_url_form_submission'), 20, 2 );
                    add_action( 'forminator_form_after_handle_submit', array( $this, 'add_redirect_url_to_hidden_field'), 10, 2);
    				add_action( 'forminator_form_after_save_entry', array( $this, 'add_redirect_url_to_hidden_field'), 10, 2);
    			}
    
    			public function get_redirect_url_form_submission( $response, $form_id ) {
    				if ( $this->form_id == $form_id ) {
                        if ( ! empty( $response['url'] ) ) {
                            $this->redirect_url = $response['url'];
                        }
    				}
    
                    return $response;
    			}
    
    			public function add_redirect_url_to_hidden_field( $form_id, $response ) {
    				if ( $this->form_id == $form_id ) {
    					$entry_meta = array(
    						array(
    						'name' => 'hidden-1',
    						'value' => $this->redirect_url
    						)
    					);
    					$entries = Forminator_API::get_entries( $form_id );
    					Forminator_API::update_form_entry( $form_id, $entries[0]->entry_id, $entry_meta );
    				}
    			}
    
    		}
    
    		$run = new wpmudev_forminator_add_redirect_url_to_hidden_field_func;
    	}
    }

    You will need to change 6 to your form’s ID and hidden-1 to your hidden field’s ID.
    You can use must use plugin:
    https://premium.wpmudev.org/docs/getting-started/download-wpmu-dev-plugins-themes/#installing-mu-plugins

    kind regards,
    Kasia

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @kevinqi ,

    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 topic if needed.

    Kind regards
    Kasia

    Thread Starter kevinqi

    (@kevinqi)

    Hi Kasia and Adam, thanks for your help. I tried the PHP code but didn’t work. Maybe because I didn’t config the hidden field right.

    I’m wondering if you can help me change the code to get the behavior’s lable not redirect url in the notification email.

    Thanks

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @kevinqi

    Sorry for the delay here.

    “I’m wondering if you can help me change the code to get the behavior’s lable not redirect url in the notification email.”

    Could you please extend it a bit just to make sure we are on the same page?

    The label should be coming from your Form > Hidden value, you can modify it or remove the label from the form builder.

    Let us know if that is what you are looking for.
    Best Regards
    Patrick Freitas

    Thread Starter kevinqi

    (@kevinqi)

    Hi Patrick, I create a php file, input the code and changed the form id, and upload the file to the mu-plugin folder, but everytime I done this, the website becomes inaccessible, and give the message “There has been a critical error on this website”, when I remove the php file from the folder, website goes back to normal.

    I tried using the plugin “Snippets”, but have no luck.

    So could you help me check the code or give me a detail process how to use this code.

    Btw, I can find the form id in the shortcode is 6157, but I am not sure the field id of the hidden field. If is was field id the letters displayed just below the field lable when I editing the form.

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @kevinqi

    Thank you for response!

    It’s difficult to diagnose the issue with code without actually checking it on site but if adding it causes Fatal Error, it usually is an issue with how the code was added – often it’s due to character encoding during “copy-paste” process or similar.

    Would you try again? This time please:

    1. First, create an empty file with a .php extension on your local drive (e.g. “forminator-add-redirect.php”); make sure there are no spaces and special characters in file name.

    Note: when you create that file DO NOT use any “full featured” editor like Word, Google docs or similar. Instead use some simple “clean text”/code editor (like Notepad++, Sublime or similar)

    2. then copy and paste code but only code directly from here:

    https://pastebin.com/raw/X7YBmEfk

    3. now again set your form ID and field ID in it. The field ID is the text in curly brackets below field name in form builder. You would see something like

    {hidden-1}

    so the field ID would be in this case

    hidden-1

    4. save the file and upload it to exactly this folder of your site: /wp-content/mu-plugins/

    Do not put it in any additional subfolder, just directly there.

    Best regards,
    Adam

    Thread Starter kevinqi

    (@kevinqi)

    The code works, thanks so much for your help.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Result of submission behavior’ is closed to new replies.