Is there a way to remove & redirect any users of a site from accessing


Unless there id is one, i have seen some examples floating around the ask if admin-ajax is being used if so redirect. how ever this is not approach i wish to make as im using admin ajax on the front end for some admins. i just don't wish them to see anything to do with the backend of wordpress.

Only userid 1 should have access to wp-admin.

  • What is the purpose of restricting users on this site? Can you just make all the users without access be Subscribers?
    – Welcher
    Apr 30, 2019 at 15:27
  • Restrict wp-admin by user role is an easier option. Apr 30, 2019 at 15:46
  • you can use this plugin wordpress.org/plugins/wps-hide-login/ Apr 30, 2019 at 16:05

3 Answers 3


There is a useful plugin dedicated for this task called : Remove Dashboard Access which allows you to remove direct access to wp-admin for all users except the admins.

  • Sorry about the late reply, Thats not bad, how ever the only admin account i wish to have access is User ID 1, Because i have admins using admin-ajax for frontend side of things. If i restrict them to a subscriber or something else they will not be able to use the admin-ajax functions. There is really no need for them to use the wp-admin dashboard
    – Mic
    May 1, 2019 at 16:39

As well you can try using WPS Hide Login plugin( https://wordpress.org/plugins/wps-hide-login/)


You could try something like:

if ( is_admin() && 1 !== absint( get_current_user_id() ) && ! wp_doing_ajax() ) {
    wp_safe_redirect( '/' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.