• Resolved martinabeldesign

    (@martinabeldesign)


    I’ve followed instructions from another site which tells you how to create a hidden dynamic text field for an Email address using New Custom Fields. Then populating the contact form To: field with that automatically (so it grabs the email from that custom field value on the page/post it’s on).

    I create the dynamic hidden email text on the form:
    [dynamichidden* recipient-email "CF7_get_custom_field key='user_email'"]
    I then created the custom field called: ‘user-email’ and added the email as the value.

    However, when I put `[recipient-email]’ into the To: field I just get a syntax error message and it doesn’t work.

    This process will be brilliant if it works. The instructions are on this link: https://sevenspark.com/wordpress-plugins/how-to-dynamically-set-the-recipient-to-email-address-in-contact-form-7

    Any ideas why that syntax error is thrown up? I’m hoping it’s not because the plugin hasn’t been updated for a while ??

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author sevenspark

    (@sevenspark)

    Hi there,

    What’s the actual syntax error you’re getting?

    Without knowing more, you said you’re using the key user_email (underscore) but created a custom field user-email (hyphen). I think you’ll need to make sure those match – switch them both to underscores.

    Thread Starter martinabeldesign

    (@martinabeldesign)

    Hi Sevenspark,
    Many thanks for your reply.
    I checked my user_email item… both were the same (sorry, typo).

    I’m putting this in the Mailto: [email protected],[recipient-email]
    But it’s throwing up red syntax error.

    I’m sure this is something very simple. What’s the correct way to add that square bracket custom field item to the email field on CF7?
    Best
    Martin

    Plugin Author sevenspark

    (@sevenspark)

    Hi Martin,

    The short answer is that I think you can just ignore that “error” – it’s really just a warning from CF7. Did you try testing actually submitting the form? It should work.

    This CF7 doc explains it: https://contactform7.com/configuration-errors/invalid-mailbox-syntax/

    Basically, CF7 is going to give you a warning there unless the mail-tag you’re using is a required “email” field, because it wants to guarantee that you’re actually getting an email address there.

    It doesn’t like the “dynamichidden” because it doesn’t guarantee it’s an email address.

    But as long as you’re guaranteeing (based on your custom field configuration) that that field is always going to be set with an email address, it shouldn’t matter.

    Hope that helps ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Email syntax error when populating To: field with dynamic hidden’ is closed to new replies.