How to make your customer happy by auto filling the form for them

I am sure you want to make your customers happy, after all happy customers are customers that hire you more or purchase more from you. One small and quick step you can do to accomplish that goal is to prefill the form as much as you can so they don’t have to fill it themselves.

To autofill fields you will need two things:

  1. A service that gives the customer previous information
  2. A form that use that service and auto fill the fields.

1. – A service that gives the customer previous information

How to retrieve your customer information highly depends on what time of site (or system) you have so a detailed explanation of this part is beyond the scope of this tutorial. For this demonstration I am just going to create a small Smart Form Extension (which you can create like this) that can give me the name, nickname and email address of the user that is submitting the form (this user needs to be logged in your WordPress site to be able to get this information). So my extension will look like this:

With this code when I call the service ‘get_user_information’ I am going to receive the name, email and username of the current logged in user in the format bellow:

Now that I have my service I just need to create a form that uses it.

2. – A form that use that service and auto fill the fields.

For this example I am going to create a form with 4 fieds:

  • Name
  • Nickname
  • Email
  • Message

The first 3 fields will be auto filled.

Now the good part =). To autofill the fields I am going to create a formula that look like this:

This formula will fill my ‘Name’ field. This formula is a little complex so it deserve a detailed explanation:

1. – Remote.Post: This is a standard Smart Forms function that will contact a service URL (in this case the URL is ‘ajaxurl’ which is explained bellow) and will automatically process the result and will use it in the formula.

2. – Ajaxurl: This is another standard smart forms function, it will always have the URL of your WordPress site.

3. – get_user_information: This is the name of the service that we created in the first section of this tutorial. Here we are basically telling our formula to contact the service called ‘get_user_information’

4. – name: The service that we created will tell us the name, nickname and email of our user. To fill the ‘Name’ field I just need the ‘name’ (I don’t need the nickname nor the email) so I am telling my formula to use specifically that part.

Having that done, I just need to copy-paste this formula into my other two fields and replace the last part of the formula.

The formula to auto fill the nickname will look like this:

And the formula to auto fill the email will look like this:

And that’s it! My form will now auto fill those fields and it will use a nice animation while loading the data making my form look very professional =)

In case you want them you can download the autofill extension and form in the zip below.


Was this tutorial useful for you? Do you want me to do a tutorial about another thing? Let me know!


  • sergio July 17, 2018 at 10:25 am

    great extension very useful, but if I want to do this same but for mysql database queries ??