Development

Useful tutor_utils() Functions with Examples

The tutor_utils() helper functions developers use most for settings, enrollment, progress, completion, courses and dashboards, with signatures and examples verified against Tutor LMS 4.1.3.

Checked against the plugin source: Tutor LMS 4.1.3, Tutor LMS Pro 4.1.3

Useful tutor_utils() Functions with Examples

tutor_utils() returns Tutor LMS's main helper object (TUTOR\Utils). It has hundreds of methods, and it also forwards calls to the model classes (courses, lessons, quizzes, withdrawals and enrollments), so tutor_utils()->is_enrolled() works even though the method lives in EnrollmentModel. These are the ones we use most, verified against Tutor LMS 4.1.3.

Always check that Tutor LMS is active before calling it: if ( function_exists( 'tutor_utils' ) ).

Settings

$engine = tutor_utils()->get_option( 'monetize_by' ); // For example 'tutor', 'wc' or 'free'.

get_option( $key, $default = false ) reads one Tutor LMS setting.

Enrollment

  • is_enrolled( $course_id = 0, $user_id = 0, $is_complete = true ): the enrollment record, or false. Pass false as the third argument to include pending enrollments.
  • get_enrolled_courses_ids_by_user( $user_id = 0 ): IDs of courses the user is enrolled in.
  • count_enrolled_users_by_course( $course_id = 0 ): number of enrolled students.

Full example: check if a user is enrolled.

Progress and completion

  • get_course_completed_percent( $course_id = 0, $user_id = 0, $get_stats = false ): progress percentage, or an array with counts when $get_stats is true.
  • is_completed_course( $course_id = 0, $user_id = 0 ): the completion record, or false.
  • is_completed_lesson( $lesson_id = 0, $user_id = 0 ): whether a lesson is done.
  • get_completed_lesson_count_by_course( $course_id = 0, $user_id = 0 ).
  • get_completed_courses_ids_by_user( $user_id = 0 ).

See getting course progress with PHP.

Course structure

  • get_topics( $course_id = 0 ): the course topics.
  • get_course_contents_by_id( $course_id = 0 ): lessons, quizzes and assignments in the course.
  • get_course_id_by( $content, $object_id ): the course a lesson, quiz, assignment or topic belongs to. $content is a type such as 'lesson', 'quiz', 'assignment' or 'topic'.

Prices and purchase

  • is_course_purchasable( $course_id = 0 ): whether the course is paid.
  • get_course_price( $course_id = 0 ): the price as shown on the site.

Users and dashboards

  • is_instructor( $user_id = 0, $is_approved = false ): pass true to require an approved instructor.
  • tutor_dashboard_url( $sub_url = '' ): the dashboard URL, optionally for a sub-page.
function tle_continue_learning_html() {
	if ( ! function_exists( 'tutor_utils' ) || ! is_user_logged_in() ) {
		return '';
	}

	$html = '';
	foreach ( tutor_utils()->get_enrolled_courses_ids_by_user() as $course_id ) {
		if ( tutor_utils()->is_completed_course( $course_id ) ) {
			continue;
		}
		$percent = (int) tutor_utils()->get_course_completed_percent( $course_id );
		$html   .= sprintf(
			'<li><a href="%s">%s</a> (%d%%)</li>',
			esc_url( get_permalink( $course_id ) ),
			esc_html( get_the_title( $course_id ) ),
			$percent
		);
	}

	return $html ? '<ul>' . $html . '</ul>' : '';
}

Notes

  • A 0 user ID means "the current user", and a 0 course ID means "the current post" in most of these functions.
  • Many results are cached per request, so they are cheap to call more than once.
  • Method names change rarely, but check them after major updates.

Building on Tutor LMS data? 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.

Vishavjeet
· Enterprise LMS Architect | WordPress & LMS Expert | WooCommerce | AI Automation

I’m Vishavjeet Choubey, an Enterprise LMS Architect with 10+ years of experience helping businesses, coaches, universities, and online academies build and scale powerful digital learning platforms. I specialize in enterprise LMS architecture, WordPress, WooCommerce, LifterLMS, LearnDash, Moodle, custom plugin development, and AI-driven automation. I build scalable LMS platforms, high-converting eCommerce solutions, and custom WordPress applications designed to improve user experiences, streamline operations, and drive measurable business growth. My approach combines deep WordPress and LMS engineering expertise with modern AI automation to reduce manual work, improve efficiency, and help organizations launch, scale, and grow faster.

Keep reading

Need a custom Tutor LMS solution?

Tell us what you are building or what is broken. A Tutor LMS developer reads every inquiry and replies with next steps and a free estimate.

Get a free Tutor LMS consultation

Tell us what you are building or fixing. A Tutor LMS developer replies with honest advice and next steps.

  • No obligation
  • Tutor LMS and Pro specialists
  • Your details stay private

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.