What if you want to land different user roles to different pages? For example, admins should land to wp-admin, wholesalers should land to some /wholesaler page, default users should land to /shop page.
function custom_login_redirect($user_login, $user) {
if( in_array( 'user_role_name_here',$user->roles ) ){
exit( wp_redirect( 'LANDING_URL_HERE' ) );
}
elseif( in_array( 'another_user_role_name_here',$user->roles ) ){
exit( wp_redirect( 'ANOTHER_LANDING_URL_HERE' ) );
}
//and so on...
}
add_action( 'wp_login', 'custom_login_redirect', 10, 2);
By using this small snippet the needed feature will start working.
Of course it is on you to change static landing URL-s with some dynamic data.
For example, one idea is integrating these URL-s with Advanced Custom Fields plugin and call those URL-s from ACF. Thus you will be able to manage those URL-s via wp-admin.
Discover more from WP DEV - Elvin Haci
Subscribe to get the latest posts sent to your email.