Skip to content

Common changes with a few lines of code (Recipes)

Reign LifterLMS Addon overviewPremiumGet Reign LifterLMS Addon →

Also called: code snippets, functions.php recipes, child theme examples, customise courses with code, LifterLMS 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 LifterLMS Add-on 2.7.0, 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.

Each member profile has a Courses tab. By default everyone who can see the profile sees it. This snippet shows the tab only to the member and to site admins.

add_filter( 'reign_llms_courses_tab_visible', function ( $visible, $profile_user_id, $viewer_id ) {
if ( $viewer_id !== $profile_user_id && ! current_user_can( 'manage_options' ) ) {
return false;
}
return $visible;
}, 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 a member profile and sees no Courses tab. The member still sees it on their own profile.

The add-on has two course page layouts: Reign default and Spotlight. You pick one for the whole site in the Course page card. This snippet gives every course in the “Design” category the Spotlight layout.

add_filter( 'reign_llms_course_layout', function ( $layout, $course_id ) {
if ( has_term( 'design', 'course_cat', $course_id ) ) {
return 'spotlight';
}
return $layout;
}, 10, 2 );

Change design to the slug of your course category. You find the slug on the category’s edit screen.

You’ll know it worked when a course in that category opens with the image behind the title. The page <body> then has the class rllms-course--spotlight.

Lessons and quizzes show a Reading mode button. It puts the lesson in one readable column, with no site header or footer. This snippet removes the button and the mode everywhere.

add_filter( 'reign_llms_reader_enabled', '__return_false' );

A student’s saved reading mode choice is then ignored. The Open lessons in reading mode setting only picks how a lesson opens, so it cannot remove the button by itself.

You’ll know it worked when a lesson page shows no Reading mode button.

Change one template: the separator on catalog cards

Section titled “Change one template: the separator on catalog cards”

Each course card in the catalog has a line such as “5 lessons · 90 minutes · Beginner”. This override changes the dot between the parts to a bar. Use the same steps for any file in the add-on’s templates/ folder.

  1. Copy reign-lifterlms-addon/templates/loop/meta.php.

  2. Paste it into your child theme at reign-child-theme/reign-lifterlms/loop/meta.php. Create the reign-lifterlms and loop folders if they are missing.

  3. In your copy, find this text.

    <span class="rllms-card__sep" aria-hidden="true"> · </span>
  4. Change the dot to a bar.

    <span class="rllms-card__sep" aria-hidden="true"> | </span>
  5. Save the file.

You’ll know it worked when the catalog cards read “5 lessons | 90 minutes | Beginner”.

Keep the @version line in your copy. After an add-on update, the Update status card lists your copy as out of date if the original changed. Then compare your copy with the new file. See Override a template and the Template reference for every file.

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 is in Hooks and filters.