• Resolved Jonathan

    (@jonathanphf)


    Having seen your tutorial (written for an earlier version of Contact Form 7?), I had a go at creating a contact form that would get its mail to: from a custom field in a post:

    I’ve created a contact form [contact-form-7 id=”867″ title=”Dynamic Recipient”] which has a hidden field :

    [dynamichidden* dynamichidden-129 “dynamichidden recipient-email "CF7_get_custom_field key=’team_member_email’ obfuscate=’on’"”]

    <label> Your Name (required)
    [text* your-name] </label>

    <label> Your Email (required)
    [email* your-email] </label>

    <label> Subject
    [text your-subject] </label>

    <label> Your Message
    [textarea your-message] </label>

    [submit “Send”]

    It gets placed in posts (with information about individual team members) with a custom field called team_member_email containing an email address.

    Under the mail tab I’ve entered [recipient-email], but it doesn’t seem to like this (it gives a configuration error) because [recipient-email] isn’t an email* field…

    What am I doing wrong?!

    Thanks

    • This topic was modified 8 years ago by Jonathan.
Viewing 10 replies - 1 through 10 (of 10 total)
  • jommartinez

    (@jommartinez)

    I have the same problem

    Plugin Author sevenspark

    (@sevenspark)

    Sounds like CF7 is just giving you a warning? Assuming it’s not actually stopping the form from working, sounds like you can just ignore it. Basically the CF7 plugin is trying to stop you from doing something “invalid”, but as long as you’re sure of what you’re doing, it shouldn’t prevent you from doing what you want.

    Thread Starter Jonathan

    (@jonathanphf)

    Thanks for getting back so quick. Unfortunately the hidden field doesn’t work – it appears as plain text in the contact form and it doesn’t place the email address into mailto:

    As @sevenspark said, it appears as “invalid input” on the form but it doesn’t prevent what the form be sent.

    Form tab:
    [dynamictext dynamicemailform "CF7_get_custom_field key='email'"]

    Email tab
    [dynamicemailform]

    @sevenspark The only issue what I spotted is what it is not possible to use obfuscate='on' on the shotcode. When it is used, [dynamicemailform] is not allowed on Email Tab

    • This reply was modified 8 years ago by raualvron.
    • This reply was modified 8 years ago by raualvron.
    Thread Starter Jonathan

    (@jonathanphf)

    Thanks @soniz. I did get it working with the code you suggested. Also after changing to dynamichidden… and after adding obfuscate=’on’! It seems it is the * that I’d added after dynamichidden that was causing the problem.

    This works:

    Form tab
    [dynamichidden dynamicrecipient "CF7_get_custom_field obfuscate='on' key='team_member_email'"]

    Email tab
    [dynamicrecipient]

    In the custom posts I’m now creating for each team member there is a custom field called team_member_email which contains their email address, and by including the shortcode for this form in the post there is now a form to send them an email directly. Contact Form 7 still tells me that there’s a configuration error but messages are arriving and the email address is obfuscated to reduce harvesting…

    • This reply was modified 8 years ago by Jonathan.

    Thank for you reply @jonathanphf but it doesn’t work as obfuscate='on' tag doesn’t do nothing. The email is showing on the DOM.

    <input type="hidden" name="dynamicrecipient" value="[email protected]" size="40" class="wpcf7-form-control wpcf7dtx-dynamictext wpcf7-dynamichidden" aria-invalid="false">

    Could you give us a hand @sevenspark?

    • This reply was modified 7 years, 12 months ago by raualvron.
    • This reply was modified 7 years, 12 months ago by raualvron.
    Plugin Author sevenspark

    (@sevenspark)

    Can you share a link where I can see the page where the obfuscate tag isn’t working? I tested your form tag locally and it is correctly obfuscated in the markup. Note that in inspector will correctly decode it, but the actual HTML doesn’t print as plain text.

    Thread Starter Jonathan

    (@jonathanphf)

    Hi, see my reply above. Sorry for not marking as resolved and not responding more quickly – my work has seen me on four flights and five different countries in the last week…

    It seems that placing * after dynamichidden may have been causing the problem. It is all working now.

    At bristolreconnect.org.uk/about/ there is a list of staff (just me so far – staff are completing theirs). The list is generated from custom posts with a custom field which is their email address. You can see the full text of the post, includimg a contact form by clicking on ‘more’ under the photo. Contact forms are generated for each member of staff that send a message to their email account.

    It works like a dream! Thanks for your great plugin!

    Alternatively, you can disable Contact Form 7 validation errors ??

    Just copy the following code to your theme’s functions file;

    add_filter( 'wpcf7_validate_configuration', '__return_false' );

    Seriously everyone. Stop using contact form 7 to edit CPT on the front-end. Its a waste of time. Use acf_form from Advanced Custom Field. It’s just magic.

    Signed a guy who waste too much time trying to make CF7 working for this feature

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Mail to from custom field in a post’ is closed to new replies.