Some sites may wish to display to users what their roles are. Here is a small module allowing just this.
Drupal user roles are typically seen only by the administrator when editing a user's account. As of 4.6.3, there seems to be no simple way to have them displayed to user when they access their own information in a theme- and theme-engine-independent way (a PHPtemplate-dependent trick is explained on drupal.org).
So the simplest way appears to be a module implementing hook_user
.
This can be added to an existing module, or coded on its own.
In this case the code is supposed to be implemented as csroles.module
,
meaning it is in a module of its own that has to be activated from
http://www.example.com/admin/modules
For site admins wishes to display the same information in a block without
adding a module to an already overloaded
site, there is a shorter way: create a custom block in
http://www.example.com/admin/block/add
,
setting the input filter to PHP code
, and type:
Tagged for drupal, sample code, and user roles in Technorati.
Is it possible to display
Don't display 'authenticated user'
foreach
loop:display user access
I would like to display all the common pages and modules, to which the user has access, based on his roles. How do i accomplish it.
Thanks
Shah
Basically you don't
Due to the menu inheritance system, that list would basically be infinite, or very large, since any path with additional components to a valid path is also a valid path.
So you probably want to only display part of that list of paths (pages). The question then becomes : exactly which pages would you display in that list ? If it's nodes, it can still be a very long list, as you can have up to 4 billion nodes on a Drupal 6 site.
I would like to display all
I would like to display all the common pages to which the user has access, based on his roles
Thanks and Regard,
-Sanjeet
Definition of "common"
The question is much too wide: which part of that near-infinite number of do you want to display ? You just can not list every possible pages a user can access; the entire universe would not be enough to hold the display since any path beyond an allowed one is allowed too.
To understand why this list is practically infinite, imagine user is allowed to see
example.com/foo
and no specific code handles any path longer thanexample.com/foo
(i.e. no menu entry forfoo/bar
, for example). Onexample.com
he will then be allowed to access any path matching regex/^foo\/\.*/
Now, why is this not infinite ? Basically because you just cannot send an infinite length URL to a server. Being infinite, it could not exist itself within a finite universe. But you get an idea of the available number of available paths.