Not sure if this is indeed a bug or even this module is the problem or not but it seemed like the best place to start.

Can someone confirm that the token [realname] when used in the core Actions 'Send a tokenized email' option, is suppose to be the realname of the email recipient? Or is it supposed to be the from the logged in user.

The placeholder token [user:name] states 'The name of the currently logged in user.' and [realname] states 'The RealName for the user.'. Other placeholder tokens that talked about 'the user' are from the recipient user and not the currently logged in user. So either this is a code problem or just a text description problem. Where the token [realname] should say 'The RealName for the currently logged in user.'.

I'm trying to send out automated emails to users after certain triggers caused by the admin's actions and it's not possible because the admin's name will output for the [realname] token.

Thanks

Comments

bburg’s picture

I'm hitting a similar problem using the [realname-link] token with the Heartbeat module (provides a user activity stream). The tokens are replaced with the currently logged in user rather than the user that the activity applies to. I've been looking at the code, and it the issue seems to be that the token module keeps pulling in global variables (with the currently logged in user), or forcing it not to, it then pulls in the referenced organic group node's author rather than the user who joined the og.

This is all in the token_replace_multiple() function to render content prior to output. A parameter, $types, contains an associative array that should in theory contain objects that set a context for the replacements (node, user etc.,). However, It's merging a bunch of static data with the passed data which is overpowering these context specific parameters.

Perhaps the solution is that any module storing data with tokens should perform a token replace prior to inserting data into the database?

bburg’s picture

Follow up:

That token_replace_multiple() function should be called without passing 'global' => NULL. Also, pass 'user' => $user before anything else, like the node.

hass’s picture

Issue summary: View changes
Status: Active » Closed (outdated)