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

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by RavindraSingh on August 22, 2012 at 3:01am

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

Posted by BrockBoland on August 22, 2012 at 11:09am

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

Posted by RavindraSingh on August 25, 2012 at 2:29am

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:

AltStyle によって変換されたページ (->オリジナル) /