One form, Dynamic Notifications for a WP Directory with a CPT

I’m building a directory. I have a CPT for each coach and a user profile they use to login to the members area.

The single page that outputs the CPT shows the coaches info (from the CPT) and has a “contact me” form that I want to re-use for all coaches.

This post is very similar I suppose: Dynamically "send to email" notification

This answer from @uamv seems like it would do the trick but it doesn’t explain how I would use this for one form on my site and what I need to modify: Dynamically "send to email" notification - #2 by uamv so that

My question: how would I modify above so that…

  1. The email address is never shown publicly - not even as a hidden field that you could view via HTML
  2. Obtain the coach’s email address which is part of their user profile (every coach user profile has a custom user field called “plh_prac_id” which I’m using for other functionality, so ideally that would be used to lookup the email)
  3. Not have to duplicate the user’s email address as part of the CPT to make looking up the email easier - if I have to, that’s fine but I prefer not

Here is some code I recently built that shows how I lookup the prac id given a user logging in to one of the site pages

$author_id = get_current_user_id();  //get currently logged in user	
$pracid = get_field('plh_pract_id', 'user_'. $author_id ); //get the CPT id from the custom user field

Any pointers would help.

Thanks!!

See all my code from above on Github here

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.