[WP Hack] Prevent Admin Access for Logged in Users
For some webdesign projects, you may need to prevent admin access for logged in users. To do so, simply paste following snippet to your functions.php file:
function prevent_admin_access() { if ( false !== strpos( strtolower( $_SERVER['REQUEST_URI'] ), '/wp-admin' ) && !current_user_can( 'administrator' ) ) wp_redirect( home_url() ); } add_action( 'init', 'prevent_admin_access', 0 );
This code will prevent any users to access administration panel. Administrators however will still be able to access the panel.
Deal Notice: We are using A2 hosting for all of our websites, and we are really happy with their service. So we wanted to share you this discount link for you to try it out. If you get a hosting using this link, you will also help us build better content for you: SSD Hosting - 300% Faster Than Standard Hard Drives