Problem/Use Case:
You may want admins to land in the dashboard while subscribers go to a custom page after login.
Snippet:
// Redirect users after login
function my_login_redirect($redirect_to, $request, $user) {
if (isset($user->roles) && is_array($user->roles)) {
if (in_array('administrator', $user->roles)) {
return admin_url();
} else {
return home_url('/welcome/');
}
}
return $redirect_to;
}
add_filter('login_redirect', 'my_login_redirect', 10, 3);Explanation:
This redirects the login logo link to your site’s homepage.
Where to Place It:
In functions.php. or a custom snippet plugin
Bonus Tip:
Pair this with a custom logo for a fully branded login page.