Allow site visitors to connect through a basic contact form on a member’s profile listing. When someone views a directory profile, they will see a form that automatically sends to the individual profile user’s email address. This can be a major feature for some listing sites, that want to enhance networking, referrals, or lead generation for their members.
The recipe below uses the popular Contact Form 7 plugin for WordPress and our Member Directory and Profile Pages Add On.
Table of contents
The Code Recipe
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.
Edit the Recipe and Contact Forms
There are three specific steps to make this recipe work for your site:
- Update line 49 with the correct shortcode for your desired form to display.
- Add this hidden field to your form directly before the submit button:
[hidden send-to-email default:shortcode_attr]
.
Settings page screenshot with the hidden “send-to-email” field on the contact form. - Update the form’s “To” field of the contact form’s email to “[send-to-email]”. The form will not display when the current user is viewing their own profile.
Add the shortcode to swap in on the “Email” field. - Note that if the email being sent through the form is formatted a plain text, you can check the box “Use HTML content type” under the Mail > Message Body setting in Contact Form 7.
Screenshot
Free Course: Membership Site Development—The Basics
Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.