• Resolved HobbyHomepagemaker

    (@hobbyhomepagemaker)


    I have added the suggested script for opening a Thank you page after customer have clicked on the Submit button in the contact form.
    Now I would like to export the customers name and emailadress and display it on my Thank you page. How can I do that? Can someone in this forum please help me create that?

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi, hobbyhomepagemaker, I’m another CF7 user.

    It looks like someone has previously written about this topic:
    https://vincoding.com/dom-events-method-passing-cf7-data/

    /* DOM event method for passing demo CF7 data */
    function vc_dom_event_footer() {
    ?>
    <script type="text/javascript">
    document.addEventListener( 'wpcf7mailsent', function( event ) {
        if ( '944' == event.detail.contactFormId ) {
            var inputs = event.detail.inputs;
    		for ( var i = 0; i < inputs.length; i++ ) {
    			if ( 'your-name' == inputs[i].name ) {
    				var yourname = inputs[i].value;
    			}
    			if ( 'your-email' == inputs[i].name ) {
    				var youremail = inputs[i].value;
    			}
    			if ( 'cf7-oldmethod' == inputs[i].name ) {
    				var cf7oldmethod = inputs[i].value;
    			}
    		}
    		window.location.href = '/cf7-thank-you/?yourname='+yourname+'&youremail='+youremail+'&cf7oldmethod='+cf7oldmethod;
        }
    }, false );
    </script>
    <?php
    }
    add_action( 'wp_footer', 'vc_dom_event_footer' );
    Thread Starter HobbyHomepagemaker

    (@hobbyhomepagemaker)

    Hi Ian,
    Thank you for your answer!

    I have looked at it but I’m having some questions on it.
    1. I’m not sure where to put the code. “This is the main part that is changing from the old on_ok_sent method. Instead of adding anything into the ‘Additional Settings’ tab in Contact Form 7, we are instead going to add a hook into the functions.php file that will insert the needed javascript code at the bottom of the page”
    I don’t know how to do that. Can you help me with that?

    2. When it’s time to fetch the data to the Thank you page the following code is suggested:

    /* custom output based on the form data
    02
    add_action( 'genesis_before_post_content', 'vc_genesis_custom_thankyou' );
    03
    function vc_genesis_custom_thankyou()
    04
    {
    05
        if(is_page('cf7-thank-you')){
    06
            $yourname = htmlspecialchars($_GET["yourname"]);
    07
            $youremail = htmlspecialchars($_GET["youremail"]);
    08
            $cf7oldmethod = htmlspecialchars($_GET["cf7oldmethod"]);
    09
            //echo your ouput as desired here using the url variables that were passed through
    10
        }
    11
    }

    I’m not sure if it will work on my webpage with the Theme Twenty Seventeen? Vincent, who created the post, says in an answer to some Jonathan that it has to be a Genesis based theme from studio press.
    Have you got any ideas how to solve that?

    Regards,
    Lotta

    Hi, Lotta, both pieces of code can be placed into your functions.php file within your theme (or use a plugin like Code Snippets to insert code).

    Since your theme is the 2017 theme, then the lower piece of code needs to be adjusted by using a different hook. Instead of using genesis_before_post_content, you could try using wp_head.

    Thread Starter HobbyHomepagemaker

    (@hobbyhomepagemaker)

    Thank you Ian for your support!
    I’m sorry for my late answer. Today a friend managed to help me solving this issue based on your support.

    Regards
    Lotta

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to export name and e-mail to Thank you page?’ is closed to new replies.