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

    Is it possible to automatically grab Wordpress user details and add them to form?

    Asked by ccranney on April 03, 2014 at 10:16 AM

    I have an uploader on our website which uses Jotform. I am integrating the uploader in to a special section of the website which requires the user to login. Is there anyway that the Jotform can detect which user has uploaded a file so I do not have to ask them again for their contact details etc?

    Page URL:
    www.hotcost.co.uk/uploader

    wordpress wp detials wordpress username get username wp user get wp username wp username
  • Profile Image
    JotForm Support

    Answered by EltonCris on April 03, 2014 at 11:51 AM

    Hi,

    That's possible but you have to use custom php script (which you can try below) in order to retrieve the information pertaining to the current logged in user on your WP site.

    Here's how:

    1. Get your iframe embed code. http://www.jotform.com/help/148-Getting-the-Form-iFrame-Code

    2. Edit your iframe embed code. Append the following URL parameter on the src value found on your iframe embed code to populate the current logged in user to the username field on your form.

    ?username=<?php global $current_user; get_currentuserinfo(); echo $current_user->user_login;?>

    username is the field name on your form where you want to populate the data.

    The final code should look similar to this:

    <iframe id="JotFormIFrame" onload="window.parent.scrollTo(0,0)" allowtransparency="true" src="https://secure.jotformpro.com/form/40924949465972?username=<?php global $current_user; get_currentuserinfo(); echo $current_user->user_login;?>" frameborder="0" style="width:100%; height:465px; border:none;" scrolling="no"></iframe>

    3. Embed the modified iframe embed code to your WP site.

    Let us know if you have difficulties implementing this. Thanks!

  • Profile Image

    Answered by ccranney on April 07, 2014 at 03:51 AM

    @EltonCris

    I have tried as above but the username is not being auto populated :(.

    Here is the code I have used:

    <iframe id="JotFormIFrame" onload="window.parent.scrollTo(0,0)" allowtransparency="true" src="//form.jotformeu.com/form/40753265708357?Username=<?php global $current_user; get_currentuserinfo(); echo $current_user->user_login;?>" frameborder="0" style="width:100%; height:1107px; border:none;" scrolling="no"></iframe>

    <script type="text/javascript">window.handleIFrameMessage = function(e) {var args = e.data.split(":");var iframe = document.getElementById("JotFormIFrame");if (!iframe)return;switch (args[0]) {case "scrollIntoView":iframe.scrollIntoView();break;case "setHeight":iframe.style.height = args[1] + "px";break;}};if (window.addEventListener) {window.addEventListener("message", handleIFrameMessage, false);} else if (window.attachEvent) {window.attachEvent("onmessage", handleIFrameMessage);}</script>

     

    Any ideas what could be the problem?

  • Profile Image
    JotForm Support

    Answered by Welvin on April 07, 2014 at 08:26 AM

    I don't see a username field to the form on this webpage: http://hotcost.co.uk/uploader/. What is the correct form URL?

    Also, please use the exact codes given by my colleague, use small caps for the field name and use just the codes below:

    <iframe id="JotFormIFrame" allowtransparency="true" src="//form.jotformeu.com/form/40753265708357?username=<?php global $current_user; get_currentuserinfo(); echo $current_user->user_login;?>" frameborder="0" style="width:100%; height:465px; border:none;" scrolling="no"></iframe>

    Still, the "username" should be the field name of your form. Let us know the form URL and we'll give you the final codes.

    Thanks

  • Profile Image

    Answered by ccranney on April 07, 2014 at 08:56 AM

    The URL is here: http://hotcost.co.uk/customer-area/pages/create-page/

     

    You will need to login, please use: 

    jotform

    Password1

     

    I only changed the username to caps as I named it as such in the form. Will this work if I hide the username field? Thanks.

  • Profile Image
    JotForm Support

    Answered by Welvin on April 07, 2014 at 10:30 AM

    Thank you. Please use the following codes:

    <iframe id="JotFormIFrame" allowtransparency="true" src="//form.jotformeu.com/form/40753265708357?username32=<?php global $current_user; get_currentuserinfo(); echo $current_user->user_login;?>" frameborder="0" style="width:100%; height:465px; border:none;" scrolling="no"></iframe>

    username32 is the field name of the "username" field. When I say "small caps", I'm referring to the actual field name, not to the field label.

    You can find the field name by following this guide: How to Find Field IDs & Names.

    Update us here for the results after using the codes above.

    Thanks

  • Profile Image

    Answered by ccranney on April 09, 2014 at 10:48 AM

    Unfortunately this is still not working, the username field is always blank when a submission is made.

     

    Any ideas what the problem may be?

     

    Thanks

  • Profile Image
    JotForm Support

    Answered by ashwin_d on April 09, 2014 at 12:04 PM

    Hello ccranney,

    Upon checking your webpage, I found that the iFrame URL has lot of unwanted character. It may be because you have copy pasted it directly from here in your html editor. Please check the screenshot below:

    I would suggest you to copy the code from the following location and that should solve your problem:  http://pastie.org/9053293

    Do get back to us if the issue persists.

    Thank you!

  • Profile Image

    Answered by ccranney on April 10, 2014 at 03:44 AM

    Thanks. I retried using that code but the issue unfortunately remains :(

     

    No username data is being transfered over. I have tried this with different people being logged in to Wordpress but it still does not work.

     

    Thanks

  • Profile Image
    JotForm Support

    Answered by EltonCris on April 10, 2014 at 08:36 PM

    @ccranney 

    The reason why it's not working because the PHP is not executed on your page. You have to install a plugin first where it allows you to execute PHP anywhere on your posts or pages.

    1. I found Insert PHP Plugin helpful. Please install this on your WP site so you can run a PHP codes. Here's how:

    2. Re-embed your form using this code:

    <iframe id="JotFormIFrame" allowtransparency="true" src="//form.jotformeu.com/form/40753265708357?username32=[insert_php] global $current_user; get_currentuserinfo(); echo $current_user->user_login; [/insert_php]" frameborder="0" style="width:100%; height:465px; border:none;" scrolling="no"></iframe>

    Insert PHP plugin usage:

    In order to run PHP, just wrap the PHP codes with [insert_php] and the closing tag [/insert_php] tags instead of <?php and ?>. Notice how this is applied to the codes above.

    Hope this helps!

    P.S. This is tested on my local WP page and it's working as expected.

  • Profile Image

    Answered by JohnReaves on June 19, 2014 at 01:44 PM

    This is exactly something I need to do.  Hopefully this thread is still active; I'll try to implement this over the next week or so.  Thanks!