我想要一个权限,这将防止人们从登录。(因此,所有用户的作用X可能是暂时阻断,同时保持他们的个人资料页。)

摘录的登录过程中从职业发展的推2nd Edition:

  1. 员额从登录的形式
  2. 用户被封锁?
  3. 拒绝用户访问控制?

我想要停止用户在三个步骤的过程。我有一个模块:

/**
 * 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
    }
}

也许我使用drupal_goto错误的。

有帮助吗?

解决方案

我没有推例来测试这个ATM机,但我认为你希望这样的:

/**
 * 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");

    }
}

删除他们的用户信息,并将其替换为与匿名用户,而不是。

其他提示

我认为,这完成你想做的事。

/**
 * 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 don't have permission to log in");

        //prevent login
        header("Location: http://www.example.com/?q=logout");
        // header("Location: http://www.example.com/logout"); if using clean URLs
    }
}

这本日志中的用户出和显示信息。如果我没有记错的话,hook_user美元op登陆火灾后的用户登录,所以这将立即记录他们马上回来-基本上使他们无法登录。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top