Support » Plugin: Contact Form 7 » Dynamically Add C7 Form Recipient – CPTs Involved

  • Resolved Howdy_McGee


    So currently I have CPT of Staff Members and inside the posts they can set Emails. What I want to do is make a page for each Staff Member where a C7 form automatically gets added and the email that the user set in the CPT is added to the C7 form. Is this possible? Does this make sense? How can it be done?

Viewing 1 replies (of 1 total)
  • So let me explain my situation first. I have a Staff CPT and with it the user would put the Staff Name in the Title of the post and an Email address in a metabox. Then on the page I add 1 Contact Form 7 form where I needed to change the email depending on what Staff page the person was viewing. I ran into this link:

    WordPress Contact Form 7 Hook Unofficial Developer Documentation and Examples

    Where I was able to make these function which will break down the URL, get post by slug, then get the meta and spit it back into the contact form. Of course this will not work for everybody, if you have categories you would need to modify the function.

    If you want to test it, what I ended up doing is adding this to my wp_config file so my form doesn’t go through AJAX

    define ('WPCF7_LOAD_JS', false);

    then I added this to my functions.php file:

    before the conditional_email() function end you would want to spit out the WPCF7 object and then die() so that the form doesn’t submit. Hopefully somebody else out there finds this useful ^_^ !

Viewing 1 replies (of 1 total)
  • The topic ‘Dynamically Add C7 Form Recipient – CPTs Involved’ is closed to new replies.