1

This may sound like a strange question but it is desired functionality from a client. They would like to have a login screen that only staff members can log in through. What I mean by that is if an anonymous user logs in, and if their role is staff (or admin) then they are logged in. If it is any other role, then they are not logged in and redirected to a 'normal' login page.

I know this seems unorthodox but is there a way to accomplish this?

Thanks.

1

Which ever role you want to allow to login give the role the permission.

Drupal 6

Please change the permission to an appropriate one. This is just for test purpose.

function modulename_perm() {
  return array('allow modulename login');
}

function modulename_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'login') {
    if (user_access('allow modulename login') == FALSE) {
      drupal_set_message('Member logins have been temporarily disabled. Please try again later.', 'warning');
      user_logout();
      exit;
    }
  } 
}

DRUPAL 7

function modulename_permission() {
  return array(
    'allow modulename login' => array(
      'title' => t('allow modulename login'), 
      'description' => t('allow modulename login.'),
    ),
  );
}
function modulename_user_login(&$edit, $account) {
 if (user_access('allow modulename login') == FALSE) {
      drupal_set_message('Member logins have been temporarily disabled. Please try again later.', 'warning');
      user_logout();
      exit;
 }
}
| improve this answer | |
  • One question, how would you make it specific to a particular login link? IE, I what regular user to login using one link and staff using another? – user5013 Oct 27 '12 at 23:24
  • @user5013 the only way I can think of is creating an alias path to the same login page like user/player/login and user/admin/login both point to user/login. You can use the pathauto module. – junedkazi Oct 28 '12 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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