WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I do not want the users (role: subscriber) to be able to login via the wp-admin.

How would you suggest I do this ?

share|improve this question

You can remove the Read capability. That will prevent all access to wp-admin.

function remove_read_wpse_93843(){   
  remove_cap( 'subscriber', 'read' );
add_action( 'admin_init', 'remove_read_wpse_93843' );

See the note in the Codex about only needing to run this once.

Then you need to hide the admin bar.

function hide_admin_wpse_93843() {
  if (current_user_can('subscriber')) {

And probably want to redirect subscriber logins:

function redirect_sub_to_home_wpse_93843( $redirect_to, $request, $user ) {
    if ( isset($user->roles) && is_array( $user->roles ) ) {
      if ( in_array( 'subscriber', $user->roles ) ) {
          return home_url( );
    return $redirect_to;
add_filter( 'login_redirect', 'redirect_sub_to_home_wpse_93843', 10, 3 );

Other attempts to access wp-admin will result in the "You do not have sufficient permissions..." almost-white screen.

That is somewhat bare-bones but I think it gets you there.

share|improve this answer
Thanks, just what I was looking for. Shall give it a shot now. – Prakash Raman Mar 29 '13 at 21:22
Tanks for your answer. It is just what I was looking for. – João Paraná Jul 13 '14 at 23:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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