4 Tricks for Capturing Additional User Data in WordPress Forms

Getting the data you need in every form submission is mission critical to running a successful campaign. Information that comes directly from the person filling out the form is easy. You just ask them for it with a field. But that’s not always enough.

Need to know the referring source the user came from?

Have multiple copies of a form on your site and need to know the specific post or page a submission was made from?

Running a multisite and want to track which URL the submission came from?

Want to capture a logged in user’s name or email without having to ask for it each time?

All of these things are very easily doable if you know how, but can be a headache to figure out your first time through. Check out these little known but very easy tricks for capturing additional user data in all your WordPress forms!

1. Capture WordPress Post and Page information with each submission

There are lots of reasons why you might want the URL of the post or page the form is being submitted from to show up either in your WordPress forms submissions or in an admin email. Most commonly we see users with a standard form placed in a widget or footer, and need to know which page the submission took place on. That’s really easy to accomplish!

  1. Add a Hidden field to your form.
  2. Set the Default Value of the field to {wp:post_url}

That’s it! If you’re wanting this in the email, be sure to include the merge tag for the hidden field in the email message body. If you’re using the {fields_table} merge tag, you’ll need to switch to the {all_fields_table} merge tag instead, or specifically include the Hidden field merge tag in addition to the {fields_table} tag.

2. Capture user data from a logged in WordPress user

Many times you’ll want to get info on a logged in user without having to ask them to fill in basic info like their name and email each time they submit a form. Ordinarily this would turn into a file editing headache, but with this trick it’s super simple.

All you need to do to capture user data in WordPress forms is:

  1. Place the receiving field on your form (Hidden if you don’t want the user to see it, otherwise a field like first name, last name, etc)
  2. Set the Default Value of the field to the WordPress user data merge tag you need.

Some of the available WordPress user data merge tags are:

  • {wp:user_first_name}
  • {wp:user_last_name}
  • {wp:user_display_name}
  • {wp:user_email}


3. Capture the WordPress site URL or Title with each submission

If you’re collecting user data into a CRM from multiple sites, you may need to keep up with the website the WordPress forms data is coming from. That’s as easy as adding a merge tag to a hidden field.

  1. Place a Hidden field on your form
  2. Insert either {wp:site_title} or {wp:site_url} as the Default Value of that field

4. Capture the referring source for each user that lands on your form

This is a little more complex, but still pretty darn simple using a merge tag. We’ll be using a querystring value to do this. If you need a primer or refresher on using querystrings, check out the full article on it.

  1. Modify the URL the user is clicking to get to your form with the querystring key/value that you need to pass the data you want. For example, ?source=twitter
  2. Place a hidden field onto your form and set its default value as {querystring:source}, where “source” is the key that you chose to use in the first step.

When the user clicks through to the form, the Hidden field will capture the Value you assigned the Key in the referring URL. In our example, it will show up as “twitter”

There’s even more data you can capture in each of your WordPress forms!

These four tricks each use a merge tag to capture the data you need. They don’t even cover all of the available merge tags at your disposal, though! For a full list of merge tags that you can use to capture user data in WordPress forms:

  1. Open your Ninja Forms builder
  2. Place a field
  3. Click the merge tag icon in the Default Value setting of that field
  4. Click on the WordPress or Other tabs of the modal that opens

Have fun seeing what data you can capture in your WordPress forms, and please let us know below if you have questions! If you have any recommendations that you don’t see here but wish we had, let us know that too. Your feedback helps steer the future of the plugin!

Hate asking a logged in user for name and email in your #WordPress form? You don't have to anymore. Autopopulate it. See how with Ninja Forms!Click To Tweet