Helping you Build Your Own Social Network!

Faster, better and easier!

stop subscribers from admin page

(2 posts) (2 voices)
  • Started 9 months ago by gwu
  • Latest reply from Brajesh Singh

Tags:

No tags yet.


  1. Hi Brajesh,

    I do not want any user other than site admin to access the wp-admin page. Is there a way to redirect users to 404 page when they try to access this page?

    Posted 9 months ago #
  2. Hi Gwu,
    here the code you can put in the functions.php or bp-custom.php

    add_action("init","redirect_subscriber");
    function redirect_subscriber(){
        if(!is_admin())
            return;
        if(is_user_logged_in()&&!current_user_can('edit_posts')){
            wp_safe_redirect (get_bloginfo ('home'));
         exit(0);
        }
    }

    It will allow all non subscribers(contributors and above to visit the dashboar but the subscribers will be redirected to site home page).

    Please do let me know if that helps or not.

    Posted 9 months ago #

Reply

You must log in to post.