WordPress redirect after login is a common need for membership sites, shops or custom dashboards. Here’s a simple way to redirect users after login without using a plugin — quick, clean and safe.
Add this to your child theme’s functions.php
file:
function qdt_redirect_after_login( $redirect_to, $request, $user ) {
// Check if user is valid and has roles
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
// Example: Redirect all subscribers to /profile
if ( in_array( ‘subscriber’, $user->roles ) ) {
return home_url( ‘/profile’ );
} else {
return home_url(); // Redirect others to homepage
}
} else {
return $redirect_to;
}
}
add_filter( ‘login_redirect’, ‘qdt_redirect_after_login’, 10, 3 );
How It Works
This WordPress redirect after login snippet checks the user’s role and sends subscribers to a custom page like /profile
. Other roles can be redirected to any page you want.
Why WordPress Redirect After Login?
Redirecting users after login helps guide them to the right place — like a dashboard, profile or special landing page. It improves UX and keeps them away from the default admin if not needed.
Common Mistake
Don’t hardcode redirects inside templates. Always use functions.php
or a custom plugin. And don’t forget to test different roles and login scenarios.
Pro Tip
Combine this with role-specific pages. For example, redirect editors to the admin, but subscribers to a front-end account page.
Don’t forget: I’ll prepare a matching 1200×630 hero image for this snippet.