This only 5 lines snippet prevent any logged user but admins to visit the wordpress dashboard.
You can log-in on the wp-login.php page.
Just copy/paste it in your functions.php in your theme folder.
- function baw_no_admin_access()
- {
- if( !current_user_can( 'administrator' ) && stristr( $_SERVER['REQUEST_URI'], '/wp-admin' ) !== false ) {
- wp_redirect( home_url() );
- die();
- }
- }
- add_action( 'init', 'baw_no_admin_access', 1 );
Comments
Post a Comment