OK, it wasn’t easy to catch, but… There is one major problem in your code…
First check you make is:
if ( is_user_logged_in() == 1 ) {
And is_user_logged_in() is based on global $current_user variable. But… As you can read in login_redirect hook docs:
The $current_user global may not be available at the time this filter
is run. So you should use the $user global or the $user parameter
passed to this filter.
So this condition won’t be satisfied – so your code won’t change anything.
You should use $user variable that is passed as param, so this should do the trick:
public function login_redirect( $redirect_to, $request, $user ) {
if ( is_a ( $user , 'WP_User' ) && $user->exists() ) {
if ( $user->has_cap( 'manage_woocommerce' ) ) {
$redirect_to = get_admin_url() . 'admin.php?page=my-page';
}
}
return $redirect_to;
}
add_filter( 'login_redirect', array( $this, 'login_redirect' ), 10, 3 );