Is there a way to check a user's role using a php snippet in Drupal 6.x? I basically want to redirect the user on login based on their role. I have an "initial signup" role that gets created immediately after signup, and upgraded to "authenticated user" when they confirm their email address (to prevent spam).
We Rock Your Web Forum » Content Management Systems » Drupal
Drupal PHP Check User Role?
(2 posts)-
Posted 1 year ago #
-
Posted 1 year ago
-
Yes, you can use the following PHP snippet to check a Drupal user's role. Basically this searches the user role array to see if that user has the specified role "initial signup." If it does, then they get redirected to the "registration-success" page. If not (this assumes they're an authenticated user), they get redirected to the "welcome" page.
global $user; if (in_array("initial signup", array_values($user->roles))) { return 'registration-success'; } else { return 'welcome'; }Posted 1 year ago #