tl;dr: Want to automate using ACF values to populate a contact form and send notification to selected staff member without revealing staff member’s email address.
For my company’s staff directory, I am using a contact form to allow visitors to send an email to staff members, rather than displaying their email address (including in the URL). This is being done to help prevent email addresses being collected by spiders/crawlers.
Currently everything is hard coded and each staff member had a link that says “Email”. When clicked, the user is brought to a Gravity Form where the staff member’s name is dynamically populated by pulling the email from the array in the the functions.php file using the user’s id which is added to the URL on the directory page. This works fine, but I am in the process of trying to automate things to reduce complexity and make it easier for future users.
I am using Advanced Custom Fields to create a custom post type for Staff Members. I have forms created to enter and update the Staff Members. However, I have to create the staff ID by keeping track of the last entry. In the Notifications of the Contact form I am using Configure Routing to match the coded email to the staff id passed from the URL.
My goal is to have a custom link on the Staff Directory page which is created by adding the post ID to the URL (contact/?postID=xxx). The on the Contact page it fetches the Staff Member’s name from postID XXX. When the contact form is submitted, it fetches the Staff Member’s email from postID XXX.
I just can figure out how to pull the pieces together without having to manually enter something.
For what it’s worth, I have the full suite of GravityWiz perks. So I can use Populate Anything and live merge tags.
Hopefully this makes sense.
[ad_2]
Staff page slug would be /staff/mary-smith.
When the contact form is submitted, you check either the slug or referrer (depending on how you’re submitting the form), get that post, and set the mailer “to” value to get_field(’email’).