Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 341231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:41:24+00:00 2026-05-12T10:41:24+00:00

I want a permission that will prevent people from logging in. (So, all users

  • 0

I want a permission that will prevent people from logging in. (So, all users of role X could be temporarily blocked, while keeping their profile pages available.)

Excerpt of the login process from Pro Drupal Development 2nd Edition:

  1. POST from login form
  2. User is blocked?
  3. User is denied by access control?

I want to stop users at step three of the process. I have a module:

/**
 * Implementation of hook_perm().
 */
function odp_perm() {
  return array('log in');
}

/**
 * Implementation of hook_user
 * lock out without the 'log in' permission
 */
function odp_user($op, &$edit, &$account, $category = NULL) {
    if ($op == 'login' && ! user_access('log in')) {
      drupal_set_message("You do not have access to log in.", "error");
      drupal_goto('logout'); //doesn't work
      drupal_goto('content/party-tonight'); //also doesn't work
    }
}

Perhaps I’m using drupal_goto wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:41:25+00:00Added an answer on May 12, 2026 at 10:41 am

    I don’t have a Drupal instance to test this on ATM, but I think you want this:

    /**
     * Implementation of hook_user
     * lock out without the 'log in' permission
     */
    function odp_user($op, &$edit, &$account, $category = NULL) {
        if ($op == 'login' && ! user_access('log in')) {
            global $user;
            $user = drupal_anonymous_user();
            drupal_set_message("You don't have permission to log in");
    
        }
    }
    

    That deletes their user info and replaces it with the anonymous user instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my web application we have many users.I want to set permission for each
Hai I want to create more users as admin and allow permission to access
I want to parse a couple of thousands XML-files from a website(I have permission)
In the AndroidManifest.xml, I have added all uses-permission, and now I want to remove
Is there a permission that will allow me to update the privacy of a
I want to build simple camel application, which will get xml from URL and
First of all I want to say that I know its bad to serve
I have a working Facebook app that most users will use just once. Leading
I want to make application that will use GPS, as we know at first
I'm doing an sql query where I want to return a list that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.