php redirect with custom user roles set and working but redirect not working for when users are logged in

If the user is logged-in, the function returns before the redirect code lower in the function.

if( is_user_logged_in() ) {
    return;
}

Since you want the redirect code to run only if the user is logged in, try this:

if( ! is_user_logged_in() ) {
    return;
}