function wp_admin_role_limiter() { if ( ( is_user_logged_in() ) && ( preg_match( '/wp-admin/', $_SERVER['REQUEST_URI'] ) ) ) { if ( !current_user_can( 'administrator' ) ) { header( 'Location: http://www.domain.com/custom-profile-page/' ); } } } add_action( 'admin_head', 'wp_admin_role_limiter' );
Keep Users Based On Role Out of WP-ADMIN
Here is a quick and dirty way to keep your users out of the WP-ADMIN area. Â I have not found a good way to redirect a user from the wp-login.php page to a custom page and not profile.php. (anyone knows, please let me know : > ). I needed this as i had a front end system for users to manage their profiles. That part needed to look like the regular theme and not like the admin area. This code can be placed in your theme's functions.php or in a plugin. You can replace "administrator" with any role that you choose.