WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] Dynamically Add C7 Form Recipient - CPTs Involved (2 posts)

  1. Howdy_McGee
    Member
    Posted 7 months ago #

    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?

    http://wordpress.org/plugins/contact-form-7/

  2. Howdy_McGee
    Member
    Posted 7 months ago #

    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:

    http://xaviesteve.com/3298/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:

    http://pastebin.com/6h4HjdJ6

    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 ^_^ !

Reply

You must log in to post.

About this Plugin

About this Topic