Autopopulate Name and Email fields based on personal log in system.

  • federmora
    Asked on December 16, 2016 at 1:04 AM

    I embedded the form on the Joomla website following these instructions 

    https://www.jotform.com/help/246-How-to-Embed-JotForm-to-Joomla-3

    As we have a log in system to our website woudl it be possible to auto-populate the fields

    Name and the field Email, based on the person's log in database?

     

     

    Jotform Thread 1013131 Screenshot
  • Chriistian Jotform Support
    Replied on December 16, 2016 at 3:02 AM

    Based from your requirements, unfortunately, it is not yet possible to import data from the database and auto populate to the form. But the possible work to do, is to import the data from the forms submission data either from CSV or Excel and combine them with JotForm submission data. You can check the Import Data App.

    Next thing to do is to prepopulate the fields in your form. Please check the Field Prepopulator App or using the prepopulating the fields using URL parameters, please read this guide: Prepopulating fields to your JotForm via URL parameters.

    If you need further assistance, please let us know.
    Regards

     

  • federmora
    Replied on December 18, 2016 at 10:47 PM

    Thank you very much.

    When customising the URL for each user where do I see the exact code I need to use for a specific field? 

    For example I see that the field "name" is as follow:

    name[first]=John&name[last]=Smith

    but I cannot figure out how the "E-mail" field looks like

    for example this code below does not work, the email field is not being populated

    email11[email]=myemail@yahoo.com

  • Chriistian Jotform Support
    Replied on December 19, 2016 at 12:19 AM

    You can follow our guide here on How to find field IDs and names. For example, in the email, since the name is email11, you can use the code email11=myemail@yahoo.com in the url to automatically fill that email field.

    Autopopulate Name and Email fields based on personal log in system Screenshot 30

    You only need to use brackets if referring to a field with multiple input such as the Full Name field or the Date field. With the full name field, you can set the name of the field and add [first] or [last] to indicate whether you want to fill up the first or last name. As in your example, the name of the Full Name field is "name" and we have a "first" to fill the first name with John and "last" inside brackets to fill up the last name Smith. name[first]=John&name[last]=Smith

    Autopopulate Name and Email fields based on personal log in system Screenshot 41

    Please let us know if you need further assistance.
    Regards.

  • federmora
    Replied on December 22, 2016 at 11:05 PM

    Very clear thank you!

    Having embedded the form on our website, and wanting to populate the fields of name and email of every user then we will have as many customized URLs as there are users right? and we would have to give every user their personal link to the form right?

    So basically it would be

    Link for USER1  John Smith

    https://www.ourwebsite.org/value-letter-form??name[first]=John&name[last]=Smith&email[email11]=user1@yahoo.com

    Link for USER2  Ann Smith

    https://www.ourwebsite.org/value-letter-form??name[first]=Ann&name[last]=Smith&email[email11]=user2@gmail.com

    and we would have to find the way to make available the right link for every user.

    Any tip you can share on how to best do it? 

  • liyam
    Replied on December 23, 2016 at 12:15 AM

    Hello,

    Let me see if I understand properly the concern: You are using Joomla and you have embedded JotForm in it, you require users to be logged in and by this, the moment the logged in user would like to visit the page with the form, you want the name and email to populate the form fields, is this correct? If so, you might not need to create custom links for each user. Here's one method I could give you, but this requires some PHP programming:

    First you will need to use text editors such as Jumi or Sourcerer to be able to use PHP in your article where you have placed your form. 

    Next: To be able to set and use the session username variable in Joomla, you will need to use this code in your Joomla page:

          $user =& JFactory::getUser();

    And this is the variable to call the username:

         $user->username;

    Your complete code:

         $user =& JFactory::getUser();
         $user->username;

    To be able to get all the information on the session of a logged in user, you might want to print the data in order to get all the references like this:

         print_r($user);

    Just by visiting the page where this code is, you will see lots of data to print on the information of the user such as the name, username, email address, etc.

    Once you are able to get the proper variables, you can then make use the prepopulation method as mentioned by Chriistian, or you can just assign it directly on your embed code. Example:

    <script type="text/javascript" src="//form.jotform.us/jsform/1231231231?email=<?php echo $user->email; ?>"></script>

    And this should prepopulate the field of your form in your joomla page with the email address of the logged in user. 

    Hope this gives an idea on how to use PHP variables to prepopulate your form in your Joomla page. What I'm not sure about on Joomla is if the first name and last name are separate, if they are together, we might need to create additional codes to parse and split the full name string from Joomla.

    If you have questions, please let us know.

    Thanks.