質問

たい許可するのを防ぐための人からのログインする(なので、すべてのユーザーの役割Xが一時的にロックされなイライト:プロフィールページをございます。)

を抜粋したもののログイン処理からプロDrupal開発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でこれをテストするためのDrupalのインスタンスを持っていないが、私はあなたがこれをしたいと考えます:

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

これは、ユーザをログアウトし、メッセージが表示されます。私は右覚えていれば、これはすぐに右に戻ってそれらをログに記録しますので、ユーザーがログインAFTER $ OPログイン火災とhook_userは、 - 。基本的にそれを作る彼らはログインできないように、

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top