This function is redirecting users on login based on their user role.
Make sure to:
login_redirect is located in wp-login.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * WordPress function for redirecting users on login based on user role */ function user_login_redirect( $url, $request, $user ){ if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) { if( $user->has_cap( 'administrator' ) ) { $url = admin_url(); } elseif( $user->has_cap( 'aussteller' ) ) { $url = home_url('/account/ausstellerbereich/'); } elseif( $user->has_cap( 'topperformer' ) ) { $url = home_url('/account/top-performer-bereich/'); } else { $url = home_url(); } } return $url; } add_filter( 'login_redirect', 'user_login_redirect', 10, 3 ); |
Create beautiful front-end registration and profile forms with custom fields. Setup member directories, custom redirects, cutomize user emails & more using the all in one user management plugin.
Get Profile BuilderCombine the power of Profile Builder with Paid Member Subscriptions to set up user registration, memberships, and recurring revenue.
Get 25% off with the bundle