[heaviest-role] and [lightest-role] only show the id which the role has in the role_weights db instead of showing the role name

CommentFileSizeAuthor
#4 role_weights-tokens-534592.patch1.35 KBpfaocle

Comments

pfaocle’s picture

Thanks for the report - can you try this piece of PHP code in a page on your site to see if it produces the same problem?

  // Token support brief test
  if (module_exists('token')) {
    print 'Running Token tests.<br />';

    global $user;
    $string = 'I am [user] with lightest role [lightest-role-id]:[lightest-role]';
    print token_replace($string, 'user', $user) . '<br />';
    $string = 'I am [user] with heaviest role [heaviest-role-id]:[heaviest-role]';
    print token_replace($string, 'user', $user) . '<br />';
  }
pfaocle’s picture

Michsk’s picture

i am not using the module anymore because of this issue, found a workaround for the same thing as i wanted without role weights.

Anyone still using the module who could try the php code?

pfaocle’s picture

Title: [heaviest-role] and [lightest-role] show id » Tokens: [heaviest-role] and [lightest-role] show user id
Version: 6.x-1.5 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.35 KB

From #578692: array exists in role_weight error, pedrofaria provided this:

The problem was that $object is not a user object, but a url alias object... obviously don't have role property...

so, i just fixed putting a user_load function....

Please, review it!

Patch looks good after a quick look, just might need to see if we can skip the call to user_load() when $user->roles is already populated.

sdsheridan’s picture

This fixed issues with path_auto as well. Using a role-based token to generate user path aliases was causing problems. Thanks, leafish_paul! I applied the fix to the 6.x-1.5 version.

Shawn

wxman’s picture

I'm using this along with the meta tags module. After updating to the 6.x-1.5 version as of today, I'm still showing [lightest-role] in all the places I set it. Does the new patch not work with the meta tags module?

chinita7’s picture

I tried patch from #4 and it's working for me.
Now I can use role name for alias. Thanks !

pfaocle’s picture

Assigned: Unassigned » pfaocle
Status: Needs review » Needs work
pfaocle’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Priority: Critical » Major
Status: Needs work » Active

Fixed in 6.x-1.x-dev - needs porting to 7.x-1.x - thanks all.

pfaocle’s picture

Issue tags: +port-to-7.x

Tagging.

pfaocle’s picture

Status: Active » Patch (to be ported)

New statuses?! Shows how long it's been :/

pfaocle’s picture

Status: Patch (to be ported) » Fixed

Also added to 7.x-1.x-dev.

Status: Fixed » Closed (fixed)
Issue tags: -port-to-7.x

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