Monday 20 January 2014

Restrict Admin Panel To Subscribers

In WordPress there are different user levels, like Administrator,Editor, Author, Subscribers. By default WordPress provides access to each and every user level but it is not need to give back end access to Subscriber, in order to restrict Admin panel access simply add the following snippet in to your functions.php file.


function restrict_access_admin_panel(){
 global $current_user;
 get_currentuserinfo();
 if ($current_user->user_level <  4) {
  wp_redirect( get_bloginfo('url') );
  exit;
 }
}
add_action('admin_init', 'restrict_access_admin_panel', 1);

No comments:

Post a Comment