How to Check If a User Is Enrolled in a Course
Check Tutor LMS enrollment in PHP with tutor_utils()->is_enrolled(), including pending enrollments, a shortcode that shows content only to enrolled students, and the database fallback.
Checked against the plugin source: Tutor LMS 4.1.3, Tutor LMS Pro 4.1.3

Whether you are building a members-only page, a custom dashboard or an integration, the first question is usually "is this user enrolled in this course?" In Tutor LMS 4.1.3 the answer is one function call.
The function
$enrollment = tutor_utils()->is_enrolled( $course_id, $user_id );
$course_id: the course ID.0means the current post.$user_id: the user ID.0means the logged-in user.- A third argument,
$is_complete, defaults totrue: only completed (active) enrollments count. Passfalseto include pending ones, such as unpaid orders.
It returns the enrollment record (an object with ID, post_author, post_date and more) or false. The method lives in Tutor\Models\EnrollmentModel; tutor_utils() forwards the call. The result also passes through the tutor_is_enrolled filter.
Example: a members-only shortcode
add_shortcode( 'tle_if_enrolled', 'tle_if_enrolled_shortcode' );
function tle_if_enrolled_shortcode( $atts, $content = '' ) {
$atts = shortcode_atts( array( 'course' => 0 ), $atts );
if ( ! function_exists( 'tutor_utils' ) || ! is_user_logged_in() ) {
return '';
}
if ( tutor_utils()->is_enrolled( (int) $atts['course'] ) ) {
return do_shortcode( $content );
}
return '';
}
Usage: [tle_if_enrolled course="123"]Bonus material[/tle_if_enrolled].
Checking several courses
To check many courses at once, fetch the list once:
$enrolled_ids = tutor_utils()->get_enrolled_courses_ids_by_user( $user_id );
$has_any = (bool) array_intersect( array( 12, 34, 56 ), array_map( 'intval', $enrolled_ids ) );
What "enrolled" means in the database
Each enrollment is a post of type tutor_enrolled: post_author is the student, post_parent is the course, and post_status is the enrollment status (completed, pending or cancel). If you must query outside WordPress, for example from a reporting tool, this read-only query matches what is_enrolled() checks:
SELECT ID FROM wp_posts
WHERE post_type = 'tutor_enrolled'
AND post_parent = 123
AND post_author = 45
AND post_status = 'completed'
LIMIT 1;
Use your real table prefix. Inside WordPress, always use the function so filters and caching apply.
Common mistakes
- Checking before Tutor LMS loads: call it on or after
init, not when your plugin file is first included. - Forgetting pending enrollments: a student who just checked out with a manual payment method is pending, not enrolled.
- Treating admins as students: admins and course instructors can view content without an enrollment if the related setting is on.
is_enrolled()still returnsfalsefor them.
Frequently asked questions
Does this work for bundles?
Yes. Pass the bundle ID; bundles are enrolled the same way (Pro).
How do I check progress, not just enrollment?
See getting a student's progress with PHP.
More helpers: useful tutor_utils() functions. Need custom access rules? Our plugin development team can help.
Save this practical guide
Add us as a preferred Google source, or ask an AI assistant to summarize this page and link back to the original guide when it is useful.
