Display CF7 field input upon submission

Conditions/features in use: Query String DKI Shortcode

Display the input of a Contact Form 7 field on the thank-you page

    what is your name?

    How to do it on your site:

    1. Created a contact form having the user name field called “your-name” and add the form to your page.
    2. Copy this code into a new HTML block inside the page
      document.addEventListener( 'wpcf7submit', function( event ) {
        var formId = 111111
        var fieldNames = ['your-name']
        var nextURL = 'your-thank-you-page'
        if(event.detail.contactFormId == formId){
          let fields = event.detail.inputs.filter(input => fieldNames.includes(input.name))
          if ('URLSearchParams' in window) {
            var searchParams = new URLSearchParams(window.location.search)
            fields.forEach(field => searchParams.set(field.name, field.value));
            var newPath = nextURL ? nextURL : window.location.pathname
            var newPathQuery = nextURL + '?' + searchParams.toString();
            window.location = newPathQuery
      }, false );
    1. Replace the value inside the formId parameter with your form id
    2. Replace the nextURL parameter with your thank-you page URL
    3. In the thank-you page, use this shortcode to display the user’s name
    [ifsoDKI type="querystring" parameter="your-name" fallback="{name}"]


    Realated templates and examples