Posted on Leave a comment

Pre-fill Your Membership Contact Form

I’ve been in the world of WordPress for quite some time now. Early on, I began using Contact Form 7 and never really parted ways with it. I’m sure it’s not the best contact form plugin any more, but I’m comfortable with it, and like “a man’s best friend”, it has never let me down.

I set it up on this site’s contact page, and I decided it might be nice to have the name and email address pre-filled in the form fields if the user was already logged in.

So I thought I’d quickly create a small bit of code that would grab the logged in user’s data and make it accessible in javascript which would then load it into the contact form fields.

Luckily, before I went down that road – I decided to search good’ol Google to see if anyone else had come up with a simpler solution. And to my surprise, Contact Form 7 now has this feature built in.

Since you’re here, there’s a good chance you have a WordPress membership website of some sorts — hopefully with a contact page — so I’ll show you how to wire this up with Contact Form 7.

First you’ll want to install the Contact Form 7 plugin: https://wordpress.org/plugins/contact-form-7/

Create your first form following these instructions: https://contactform7.com/getting-started-with-contact-form-7/

My form looks like this:

To pre-fill data you will add the default:user_meta_key_here option in your fields shortcodes. You can find a full, unfortunately limited list of user meta keys here: https://contactform7.com/setting-default-values-to-the-logged-in-user/

I used default:user_first_name and default:user_email to pre-fill the Name and Email address fields respectively. When viewing the contact form from the front-end when logged in, the fields are now pre-filled with the available information.

Do you know of other contact forms that make this possible too – or are even easier to use? If so, I’d love to hear about it, so drop me a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *