Tokens are not evaluated

thomas23@drupal.org - August 22, 2008 - 15:54
Project:Token
Version:6.x-1.11
Component:Token Actions
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

When using action "redirect to tokenized url" and token [account-url] I'm redirected to example.com/%5Baccount-url%5D so it seams the token is not evaluated at all. With URL field value of user/[uid] users are redirected to example.com/uers/%5Buid%5D. Maybe it's because users are not logged in when the page is generated? Can this redirection calculation be changed to a later stage when the user has been logged in already or is this, by design, not possible? I hope the former is the case!

I trigger this action after user login. Unfortunatelly this only applies to /user and not the login block.

Cheers.

#1

greggles - August 22, 2008 - 17:04

Here are the steps I took to repeat this bug:

1. Create a new action from "redirect to a tokenized url" with the URL "user/[user-id]"
2. Visited admin/build/trigger/user where I assigned that trigger to "After a user has logged in"
3. Log out
4. Log in

Result:
No redirection to any place.

So, that was weird to me. I then changed around the code a little bit to debug it:

function token_actions_goto_action($object, $context) {
  $context['global'] = NULL;
  if (!empty($context['node']) && empty($context['user'])) {
    $context['user'] = user_load(array('uid' => $context['node']->uid));
  }
  $a = token_replace_multiple($context['url'], $context);
  drupal_set_message($a);
  drupal_goto($a);
}

And logged out and logged in. What this does is display the URL that is going to be redirected before doing the redirection. Interestingly enough, the output was user/1 (which is right) but I never got redirected.

So, it doesn't work for me either but I can't repeat the same bug that you have. Very strange...

#2

kiamlaluno - August 27, 2008 - 05:33

If you are using Drupal 6.4 (and maybe Drupal 6.3), the redirection to the user page made when the user logs in is automatically done by Drupal core, without the need to set anything else.
If you are using any other Drupal versions, the page /user redirects a logged in user to his user page.

#3

kiamlaluno - August 27, 2008 - 06:32

I have the same problem, but using the token '[uid]'.
I think this happens because the token action doesn't load the user object all times. It loads it if the context doesn't have an user object but it has a node object; in the case the context passed doesn't have both of them, the user object will not be loaded, and (I guess) the user tokens could not be replaced.

I don't have any problem using the '[user-id]'.

Actually, this happens with the development snapshot, but I think the token_actions.module is not changed from the 6.x-1.1 version, and the 6-x.1.x-dev one.

#4

kiamlaluno - August 27, 2008 - 06:33
Component:Code» Token Actions

#5

greggles - October 14, 2008 - 15:41

@Kiam - are you using the core trigger/actions module or are you using rules?

#6

kiamlaluno - October 15, 2008 - 11:28

The issue I reported is referred to the use of the Token actions module with the core trigger/action module.

#7

rmassamiri - November 11, 2008 - 03:43

I am having the same problem as the original author. I am using Drupal 6.6, Token 6.x-1.11, Token Actions 6.x-1.11, and have tried Rules 6.x-1.0-beta3 and Rules 6.x-1.x-dev. I noticed that the current dev version of Rules does not have a 'Page redirect with token' option. Has anyone discovered the problem or the solutions? Thanks.

#8

kiamlaluno - November 11, 2008 - 19:14
Title:tokenized url redirection action not evaluating» Tokens are not evaluated

#9

mariuss - March 31, 2009 - 04:49

Running into the same problem, it looks like none of the tokens in the "User tokens" group are available.

Beware that [user-id] is not the same thing, it points to the currently logged in user, which is not necessarily the user being edited.

#10

benone - October 26, 2009 - 16:50

subscribe

#11

benone - October 26, 2009 - 17:09

I set action for tokenized redirect and in Users Triggers I set - Trigger: When a user's profile is being viewed.
I have no idea which token let me for example go from user/23 to profile/ana

[user], [user-raw], [title], .......
None of them is working... Any suggestions ?

 
 

Drupal is a registered trademark of Dries Buytaert.