Skip to content

Common changes with a few lines of code (Recipes)

Reign Tutor LMS Addon overviewPremiumGet Reign Tutor LMS Addon →

Also called: code snippets, functions.php recipes, child theme examples, customise courses with code, Tutor LMS add-on hooks examples

Each recipe below makes one change that site owners often ask for. Copy the snippet, paste it into your child theme, and save. Every snippet was tested with Reign Tutor LMS Addon 2.3.0, Tutor LMS 4, Reign 8.1.0 and the official Reign child theme.

  • Install and activate the Reign child theme. Changes in the parent theme are lost when Reign updates.
  • Open the child theme’s functions.php. Paste each snippet at the very end of the file.
  • Edit files through your host’s file manager or SFTP. If a snippet has a typo, the site can show an error. You can then fix the file the same way.

Try each change on a staging copy first if your site is busy.

Hide the Courses tab from logged-out visitors

Section titled “Hide the Courses tab from logged-out visitors”

Each member profile can have a Courses tab. This snippet hides it from people who are not logged in. Logged-in members still see it.

add_filter( 'reign_tutor_courses_tab_visible', function ( $visible, $profile_user_id, $viewer_id ) {
return $viewer_id ? $visible : false;
}, 10, 3 );

The filter hides the menu item and the page together, so nobody lands on an empty tab.

You’ll know it worked when a logged-out visitor opens an instructor’s profile and sees no Courses tab.

Remove the length and student count from course cards

Section titled “Remove the length and student count from course cards”

Course cards can show how long a course takes and how many students joined. This snippet removes both from every card.

add_filter( 'reign_tutor_card_students', '__return_false' );
add_filter( 'reign_tutor_card_parts', function ( $parts ) {
return array_values( array_diff( $parts, array( 'duration' ) ) );
} );

The other parts you can remove the same way are instructor, category and progress. The student count only shows when Tutor LMS itself is set to show it.

You’ll know it worked when the cards on the Courses page show no clock and no student count.

Cards come in three styles: classic, soft and list. You pick one for the whole site in the Course cards card. This snippet uses the list style only on course category pages.

add_filter( 'reign_tutor_card_style', function ( $style ) {
return is_tax( 'course-category' ) ? 'list' : $style;
} );

You’ll know it worked when a course category page shows one course per row, and the main Courses page keeps your usual style.

Section titled “Change one template: show related courses as a simple list”

The course page ends with a related courses section that shows full course cards. This override turns it into a plain list of course names. Use the same steps for the other two files in the add-on’s templates/ folder.

  1. Copy reign-tutorlms-addon/templates/course/related.php.

  2. Paste it into your child theme at reign-child-theme/tutor/reign/course/related.php. Create the tutor, reign and course folders if they are missing.

  3. In your copy, find the block that starts with tutor_load_template( and ends with );. It is the last thing in the file.

  4. Replace that whole block with these lines.

    ?>
    <ul class="my-related-list">
    <?php while ( $query->have_posts() ) : ?>
    <?php $query->the_post(); ?>
    <li><a href="/reign-family/reign-tutor-lms-addon/developer-guide/</?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
  5. Save the file.

You’ll know it worked when the related courses section on a course page shows course names as links, with no images or buttons.

Keep the @version 2.3.0 line in your copy. After an add-on update, the settings screen lists your copy if the original changed. Then compare your copy with the new file. See Template overrides.

Open functions.php again through your host’s file manager or SFTP. Remove the snippet you just added and save. The site comes back straight away.

Yes. The PHP snippets work the same in a snippets plugin. The template recipe needs the child theme, because it is a file.

Every hook the add-on offers, with more examples, is in Hooks and filters.