What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.

  • Profile Image

    How can I capture the email of a logged-in user on WordPress?

    Asked by lucash on February 08, 2017 at 08:57 AM

    Users must be logged in to submit my form, so I'd like to capture their email address from their login info rather than forcing them to type it. I've tried following the steps on this thread, but haven't gotten it to work.

    I installed Insert PHP.

    Form URL: https://www.jotform.com/build/70254644192152

    Code I've tried (I know it's long; I got it straight from JotForm):

    <iframe id="JotFormIFrame-70254644192152" onload="window.parent.scrollTo(0,0)" allowtransparency="true" src="https://form.jotform.com/70254644192152"?email=[insert_php] global $current_user; get_currentuserinfo(); echo $current_user->user_email;[/insert_php] frameborder="0" style="width:100%; height:909px; border:none;" scrolling="no"> </iframe> <script type="text/javascript"> window.handleIFrameMessage = function(e) { var args = e.data.split(":"); var iframe = false; if (args.length > 2) { iframe = document.getElementById("JotFormIFrame-" + args[2]); } else { iframe = document.getElementById("JotFormIFrame"); } if (!iframe) return; switch (args[0]) { case "scrollIntoView": iframe.scrollIntoView(); break; case "setHeight": iframe.style.height = args[1] + "px"; break; case "collapseErrorPage": if (iframe.clientHeight > window.innerHeight) { iframe.style.height = window.innerHeight + "px"; } break; case "reloadPage": window.location.reload(); break; } var isJotForm = (e.origin.indexOf("jotform") > -1) ? true : false; if(isJotForm && "contentWindow" in iframe && "postMessage" in iframe.contentWindow) { var urls = {"docurl":encodeURIComponent(document.URL),"referrer":encodeURIComponent(document.referrer)}; iframe.contentWindow.postMessage(JSON.stringify({"type":"urls","value":urls}), "*"); } }; if (window.addEventListener) { window.addEventListener("message", handleIFrameMessage, false); } else if (window.attachEvent) { window.attachEvent("onmessage", handleIFrameMessage); } if(window.location.href && window.location.href.indexOf("?") > -1) { var ifr = false; if (args.length > 2) { ifr = document.getElementById("JotFormIFrame-" + args[2]); } else { ifr = document.getElementById("JotFormIFrame"); } var get = window.location.href.substr(window.location.href.indexOf("?") + 1); if(ifr && get.length > 0) { var src = ifr.src; src = src.indexOf("?") > -1 ? src + "&" + get : src + "?" + get; ifr.src = src; } } </script>

    Page URL:

  • Profile Image
    JotForm Support

    Answered by Kiran on February 08, 2017 at 10:03 AM

    Please allow me some time to check on this on my local installation of WordPress and get back to you.

    Thank you for your patience. 

  • Profile Image
    JotForm Support

    Answered by Kiran on February 08, 2017 at 12:40 PM

    Thank you for being patient. I have checked the code that you are using and see that a double quote (") in the code is misplaced which is causing the issue. Please remove the double quote after the form ID and place it after the [/insert_php] tag and the form should be displaying the email of the user logged in.

    So, you can place the code below to the WordPress web page.

    <iframe id="JotFormIFrame-70254644192152" onload="window.parent.scrollTo(0,0)" allowtransparency="true" src="https://form.jotform.com/70254644192152?email=[insert_php] global $current_user; get_currentuserinfo(); echo $current_user->user_email;[/insert_php]" frameborder="0" style="width:100%; height:909px; border:none;" scrolling="no"> </iframe>

    This is working on my local installation. Please change the form embed code on your web page with the above code and let us know if you need any further assistance. We will be happy to assist. 


  • Profile Image

    Answered by lucash on February 08, 2017 at 01:19 PM

    Thanks, Kiran! It's working.