Tutor LMS: Land on the Tutor Dashboard After Logging In
Sends students who log in through wp-login.php to the Tutor LMS dashboard instead of the WordPress admin profile.
Opens WPIDE on
Code
if ( ! function_exists( 'tutor_utils' ) ) {
return;
}
add_filter( 'login_redirect', function ( $redirect, $requested, $user ) {
if ( ! $user instanceof WP_User || user_can( $user, 'edit_posts' ) ) {
return $redirect;
}
if ( $requested && false === strpos( $requested, admin_url() ) ) {
return $redirect;
}
$dashboard = tutor_utils()->tutor_dashboard_url();
return $dashboard ? $dashboard : $redirect;
}, 10, 3 );
Notes
Staff who can edit posts still go to wp-admin, and explicit redirect_to links are respected.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.