If you want for example to redirect the user to the home url if it’s not have admin permissions?
Here the code:
function my_login_redirect( $redirect_to, $request, $user ){ // Is there a user to check? if( is_array( $user->roles ) ) { // Check if the user have admin permissions if( in_array( "administrator", $user->roles ) ) { // Redirect to admin return admin_url(); } else { return home_url(); } } } add_filter("login_redirect", "my_login_redirect", 10, 3);