Login redirect

  • Posted in : Efor
  • adrian.wilde@choiceshomes.co.uk
    Participant

    Hi, How do I make it so that when a certain role logs in they are auto directed to a specific start of a course/lesson?

    Also can I make it so that they dont have to click anything/enroll button once logged in to be enrolled into the course?

    serkan
    Moderator

    Hi,
    1. Tutor LMS doesn’t have a built-in login redirect feature, so we’ll use a custom function in your theme’s functions.php or a snippet plugin (like Code Snippets).

    add_filter( 'login_redirect', 'tutor_auto_redirect_after_login', 10, 3 );
    
    function tutor_auto_redirect_after_login( $redirect_to, $request, $user ) {
        if ( isset( $user->roles ) && is_array( $user->roles ) ) {
            // Replace 'subscriber' with your desired role (e.g., 'tutor_student')
            if ( in_array( 'subscriber', $user->roles ) ) {
                // Replace with your course/lesson URL
                return 'https://choiceshomes.co.uk/letslearn/course/lesson-1';
            }
        }
        return $redirect_to;
    }

    2. Auto-Enroll Users in a Course (Without Manual Enrollment)
    Go to Tutor LMS → Courses.
    Edit your course.
    Under “Course Settings” → “General”, set:
    “Course Access Mode” → “Open” (No enrollment required).
    (Optional) Enable “Strict Mode” if you want to restrict content until users are logged in.
    Users will now see all lessons without needing to enroll.
    Limitation: This makes the course completely public, which may not be ideal if you want role-based restrictions.
    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register