By monkfish4d on
Hello,
Is there a good way to test if the currently logged in user belongs to a role called Trade?
I know this will let me test if they're logged in...
if ($logged_in) {
Thanks for your help, N
Hello,
Is there a good way to test if the currently logged in user belongs to a role called Trade?
I know this will let me test if they're logged in...
if ($logged_in) {
Thanks for your help, N
Comments
User->roles
User object has roles array with role id as a key and role name as its value.
-------------------------------
Drupal Howto's and tips at Drupal HowTo Resouce
jQuery howto's and tips at jQuery HowTo Resouce
Thanks for your reply... I'm
Thanks for your reply...
I'm also new to PHP but I'm guessing that the $user->roles is an Array?
Is there a command to loop through it and test is Trade exists in there?
Thanks,
Nick
p.s. I'm thinking I need to be asking these Q's on a PHP forum? :)
No need to iterate through
No need to iterate through the array. You can use php's in_array function to do it for you:
or you can search on the Role ID using array_key_exists
User->roles
Sorry double post.
It seems that we don't have "delete own comments" permission :)
What you want is: <?php
What you want is:
Thanks to http://www.bywombats.com/blog/ryan/10-25-2007/checking-if-drupal-user-ha...