admin管理员组

文章数量:1430840

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.

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

https://www.example/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.

Share Improve this question edited Apr 30, 2019 at 18:06 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Apr 30, 2019 at 13:59 MicMic 101 3
  • What is the purpose of restricting users on this site? Can you just make all the users without access be Subscribers? – Welcher Commented Apr 30, 2019 at 15:27
  • Restrict wp-admin by user role is an easier option. – Luke Cavanagh Commented Apr 30, 2019 at 15:46
  • you can use this plugin wordpress/plugins/wps-hide-login/ – Miss Tahereh HZ Commented Apr 30, 2019 at 16:05
Add a comment  | 

3 Answers 3

Reset to default 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.

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

You could try something like:

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

本文标签: Hide Wordpress “wpadmin” dashboard to User IDS