• Hello,

    My existing website already has a lot of posts (custom post types) and they all have desired recipient emails stored in a custom field “_recipient”.

    Now I want to display CF7 in sidebar, probably as a button that opens a modal form (still researching this part) and have the form send to “_recipient” from this post custom field.

    How can I do this?

    https://wordpress.org/plugins/contact-form-7-dynamic-mail-to/

Viewing 1 replies (of 1 total)
  • Plugin Author John Huebner

    (@hube2)

    I created this as part of 3 plugins to do something very similar. Combine this with my hidden field plugin. I think it can also be done using the dynamic text extension.

    Add a hidden field that is populated dynamically, for example: “hidden-post-id” and dynamically populate this with the current post ID.

    add another hidden field to the form with the name “dynamic-mail-to-filter”. This fields value needs to be the name of the filter to run, the “hook” that will be used in apply_filters($hook_name, $recipient, $args)

    create a third hidden field named “dynamic-mail-to-fields”. The value of this field would be “hidden-post-id”. This will be passed to your filter as part of $args.

    In your filter get the recipient value from the post and return it. In this case the first hidden field could be dynamically populated with the exact recipient rather than the post id, but I wouldn’t do that since it will make the email address visible to bots and I’d prefer the first method.

Viewing 1 replies (of 1 total)
  • The topic ‘Specify a custom field to pull recipient email’ is closed to new replies.