How to Restrict Admin Access to wp-admin in WordPress

How to Restrict Admin Access to wp-admin in WordPress

restrict admin access to wp-admin in wordpress

Ever think of how to restrict admin access to wp-admin in wordpress? WordPress rapidly developed and became major CMS system for most of the content website. Some wordpress allow user registration and also subscription service to their web portal. For security reason, it’s always better to restrict only admin can access into wp-admin in WordPress publishing system.

Restrict Admin Access to wp-admin in WordPress – Files to Edit

There are plugins out there which you can install and restrict admin access to wp-admin in WordPress. But sometime the plugins might crash with your other plugins which already installed and configure in your WordPress system. So it’s better to do some minor hack on coding in order to avoid plugins crash or conflict with your wordpress system.

There is only 1 file needed to edit in order to restrict admin access to wp-admin in wordpress. Find the file name functions.php. This file usually appear in your theme folder, i.e wp-content/themes/twentyten/functions.php

Restrict Admin Access to wp-admin in WordPress – Code Hacking

Below is the the code which you need to add into functions.php. Please it at the bottom of functions.php before the curly close bracket “}”. This code will check whether the user has admin privilege, it the user doesn’t have admin privileges, it will redirect and land the user on the home page.

Restrict Admin Access to wp-admin in WordPress – How to Change?

There are several option to edit the code in WordPress.

  • Theme Editor – In WordPress admin dashboard, go to Appearance > Editor, look for the file functions.php and add the code at the bottom before “}” curly bracket as the instruction show above.
  • FTP/SFTP – Alternatively, if you have FTP/SFTP access, you can download the file functions.php and save a copy for backup, and upload with the code needed to add. Just in case if there is anything not working on your WordPress system, you can restore the file again
  • Command Line – If you have direct SSH access to the server, you can make the changes as show above. But, please backup your original functions.php file before adding new code.

We hope that above tutorial will you to restrict admin access to wp-admin in worpdress system. Do leave comment if you encounter any problem and we will guide you through it. Alternatively you can search for plugin in wordpress which can help to restrict admin access to wp-admin in wordpress if you do not have much plugins install and configured on wordpress system