WordPress

How to Limit WordPress Dashboard Access

From the WordPress admin dashboard you can easily control everything on your website. Your dashboard is the key to all your website access. You can select the users who you want to give those access. You can limit the access of your users from the WordPress admin dashboard.

There are a lots of reason you need to limit the user access. If you run a multi author or a subscription base website then you need to limit the functionality of others users. You can also block your subscriber to view your dashboard.

Whatever your reason is, here in this article we will show you how you can easily limit WordPress Dashboard Access.

Limit WordPress Dashboard Access

Limit dashboard access with user roles and permission

From WordPress user roles you can select who can see what part of your website. With different roles user can have different access and ability to do in your site. The owner can select the roles so that everyone can only access theirs assign part. User with access of writing post and comment don’t have the capability to change any theme settings. WordPress has many different user roles. They are –

  • Subscriber: It has only limited capability. The user can only access their profile.
  • Contributor: This user role are able to write post in your website but the don’t have the power o publish it.
  • Author: They can manage and publish their post in your website
  • Editor: Editor can publish and manage post as well as they can publish other user’s post.
  • Admin/Super admin:  Has access to website administration features. Super admin is available with multi site.

Each roles has each capabilities. So you can manage your users easily by giving them their user role. You can change the role from Users > All Users from the dashboard.

Limit dashboard access with code

This little code will block non-administrators user to access website’s back-end. This will allow to have access with only  admins and others users will be redirected to the home page. This snippets will only work when a user logs into the WordPress dashboard. It won’t apply to any user that’s not non-logged, because they wouldn’t have any dashboard access, to begin with. You need to put this code into your child theme’s function.php file

add_action( ‘init’, ‘blockusers_init’ );
function blockusers_init() {
if ( is_admin() && ! current_user_can( ‘administrator’ ) &&
! ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}

By using this method you can ensure users what they need to complete their task on your website. This is not limited to just the Contributor role, of course, so the same can be applied to other user roles and capabilities depending on your needs.

You Might Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *