0

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

https://www.example.com/wp-admin/

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.

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

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.

1
  • 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 '19 at 16:39
0

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

0

You could try something like:

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

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.