I can't seem to find a token that will address the notify email to the person who receives it. The default "Hi [user:name]" gives the name of the person who made the comment. All who are subscribed get the same greeting.

Comments

greggles’s picture

This may not be currently possible.

codeforkjeff’s picture

Here's a patch to tie the "user" token to recipient user, instead of logged-in user.

The code to load the recipient user was actually already in place, so this was a simple change.

It's a fairly localized change so shouldn't affect anything else, but I'd appreciate feedback.

jcw’s picture

Confirmed: patch #2 works (applied after patches #20 and #21 at http://drupal.org/node/952072).

greggles’s picture

Title: Recipient name not available » Provide tokens for notification recipient
Category: bug » feature

Ideally both tokens should be available. There's a chance you'd want a message:

"Hi [recipient:name],

[comment:author] just commented on a thread to which you are subscribed."

So, I think we should provide a new set of user tokens for the recipient.

codeforkjeff’s picture

When would we ever use the [user] token? Info about the user who's leaving the new comment should always be looked up through the [comment] token (as in the example in #4), since that might contain a name, which you lose if you use the Anonymous user.

For clarity, I think recipient should replace user. I don't think it makes sense to have both.

greggles’s picture

That does seem unlikely that people need the global $user token, but it seems like a major "drupalwtf" if "user contains tokens for the global user 99% of the time, but in comment_notify it contains tokens for the recipient."

dave reid’s picture

I don't see why we'd need to provide another set of tokens? There's only two people involved, the person getting the notification, and the person who made the comment. The former is [user:*] and the latter is [comment:author:*]. The [user:*] token is never the global user and is always required to be provided with a user account object; the current user token is [current-user:*].

greggles’s picture

So...I guess I forgot that in Drupal 7 the [user] token is separate from the [current-user] token?

Dave, are you saying you're +1 for the patch in #2?

codeforkjeff’s picture

On second thought, I don't think there should be ANY user tokens at all. It's not always users involved, but comments.

There should be TWO comment tokens: the new comment that was just created, and the comment that asked for notification (called "recipientcomment" maybe).

This is because anonymous users can request notifications, and if the email template wants to properly address them, it needs to use something like "Hi [recipientcomment:author]", and not the anonymous user record.

pepino’s picture

subscribing

dave reid’s picture

Status: Active » Fixed

We have a [comment-subscribed:*] token type now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.