Right now i want to restrict all anonymous users to a specific page. I know you can do this with rules by setting the condition if they are anonymous have them redirected to another page. But how can this be done via code? Also I need to add exceptions to the redirect as I dont want users redirected out of user/login page, but everywhere else.
1 Answer
I think something like below should work.
function modulename_init() {
global $user;
$args = arg();
if(!user->uid && ($args[0] == 'user' && $args[1] == 'login')) {
drupal_goto('page_you_want_anony_to_redirect_to');
}
}