How to redirect the page by using their Roles in D7?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
RavindraSingh's picture

Example is below mentioned given
global $user;
$author = false;
foreach ($user->roles as $roleid => $rolename)
{
if (strtolower(trim($rolename)) == 'author')
{
$author = true;
break;
}
}
return $author;

Comments

Where you've

BrockBoland's picture

Where you've got:

<?php
$author
= true;
break;
?>

Instead do:

<?php
drupal_goto
('some/path');
?>

But, if you want to do multiple different redirects based on roles, and want to manage that configuration later, I would use Rules.

perfact

RavindraSingh's picture

rules can be used as well.

Washington, DC Drupalers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week