How to block customer from accessing WP Admin in WordPress

wordpress logoPreviously we already show you how to hide the admin bar from non admin user. Today, we are going to show you how to block the customer or non admin user from accessing the wp admin area. To be safe, hiding the admin bar is not enough, because if customer are WordPress user they might know the exact url. So, it’s always good to block non-privilege user to access the wp admin, especially your customer if your are using Woocommerce.

How to block Woocommerce customer from accessing WP Admin in WordPress


  • Open your theme functions.php file and copy and paste the code below at the bottom of the file:-

    or there is another way using admin-init hook

    * if non admin user access wp-admin, the user will be redirect to home page again.

Share this with your friends:-

Leave a Reply