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;
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)