1

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 1

3

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');
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.