Download & Extend

Tokens: [heaviest-role] and [lightest-role] show user id

Project:Role Weights
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs review

Issue Summary

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

Comments

#1

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?

<?php
 
// 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 />';
  }
?>

#2

Marked #533186: auto assign role and role weights as duplicate issue.

#3

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?

#4

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

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.

AttachmentSize
role_weights-tokens-534592.patch 1.35 KB

#5

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

#6

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?

#7

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

nobody click here