function redirect_subscribers_after_login( $redirect_to, $request, $user ) {
    if ( isset( $user->roles ) && is_array( $user->roles ) ) {
        if ( in_array( 'subscriber', $user->roles ) ) {
            return home_url(); // Reindirizza alla homepage
        }
    }
    return $redirect_to;
}
add_filter( 'login_redirect', 'redirect_subscribers_after_login', 10, 3 );