1

This is scenario which I try to reach on my website for free blogging:

  1. There is created universal webform Contact author with fields name, email and text which is as block (display webform as block checked) displayed under every blog node type.

  2. When reader submit this block, submitted values are send as email to author of blog post (node author), site admin (me) and possibly to submitter (reader) email.

Is there any possible solution involving webform? What's best combination of modules to do it so, if not webform (I prefer some webform solution)?

Update: For Webform 4.x I use token [current-page:node:author:mail] for "E-mail to address" in "E-mails" tab. You can find more details in this tutorial I wrote.

1 Answer 1

2

The best solution (IMHO) doesn't actually work: you should be able to use the Tokens module and use a proper token to fill a recipient field. For example: [node:author:mail]

However, Webforms only appears to support its own %something tokens, and those only relate to the current user and the webform id (not the id of the node being read).

So instead, write the site's inevitable custom module and use hook_mail_alter() to change the To address.

Another resource I read (and have now lost) suggested setting the Webforms recipient to something easily recognizable, like "[email protected]".

Then in your hook_mail_alter() function,

  1. confirm the form's identity,
  2. get the current post's author,
  3. get that user's email address, and
  4. use it in the Recipients. (Along with the admin & the poster, as you like.)
5
  • 1
    You can use tokens in webform, can't you? This thread shows it was added, at the same time removing some tokens people was using. And it seems people succesfully used my solution to add additional tokens in webform. Your answer seems to be in opposition to what I've learned.
    – Mołot
    Commented Jun 12, 2013 at 12:22
  • @Molot, Maybe the difference is in the version, something I didn't ask Jasom about at the time. It looks like they added proper, Drupal-style Tokens to the 4.x alpha version. I would have been using the stable 3.x version on a production site. Also, thanks for your link to your solution just for the token-implementation example! Commented Jun 16, 2013 at 14:13
  • -- Jasom, if this is still relevant to you, what version of Webform are you using? As Molot points out, if you can use v. 4, you can use Tokens. Commented Jun 16, 2013 at 14:19
  • 1
    Guys, do you know what is funny? 2 years later Google returned this page for me, I'm reading the question (with "bla bla, too much text, what's the best answer" in my mind) and then I found out that I wrote this question :D :D Right now, I'm using Webform 4.x Commented Sep 1, 2015 at 22:00
  • Here's a tutorial how to send email to the current node author jasom.net/… Commented Sep 4, 2015 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.