By stoob on
Hi, using Drupal 5.x...please help if you have insight.
I would like to, based on user role, use a different query in my module to display results.
For example.
If role "administrator"
$query = "SELECT * FROM `table`;
If role "anonymous user"
$query = "SELECT * FROM `table` WHERE 'public'=1;
Any thoughts on how to go about this?
Comments
use the roles array
Use the $user->roles array.
Though, if you have more anonymous users, you may want that $user->uid == 0 check first, to save you (a small bit of) processor time.
Thank you this worked great.
Thank you this worked great. At first I got an error because global $user was not in the function. I got a "wrong datatype" warning when this was the case. Adding $user to the function fixed that. That was my only small problem. Thanks for the help.