If you want to redirect all /wp-admin
address you can use:
add_action( 'admin_init', 'redirect_so_15396771' );
function redirect_so_15396771()
{
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
return;
// http://codex.wordpress.org/Roles_and_Capabilities
if ( !current_user_can('delete_users') ) {
wp_redirect( site_url( '/login/customdashboard/' ) );
exit();
}
}
If you need to filter this according to the current page, you can use the global $pagenow
, which has the values index.php
, profile.php
, tools.php
, etc.