Common changes with a few lines of code (Recipes)
Also called: code snippets, functions.php recipes, child theme examples, customise courses with code, Sensei 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 Sensei Addon 2.0.0, Sensei LMS, Reign 8.1.0 and the official Reign child theme.
Before you start
Section titled “Before you start”- 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.
Show the Courses tab only to the member
Section titled “Show the Courses tab only to the member”Each member profile has a Courses tab. By default other people see it too. This snippet shows the tab only to the member and to site admins.
add_filter( 'reign_sensei_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.
Use one cover picture for a whole category
Section titled “Use one cover picture for a whole category”With the Cover layout, the course picture fills the header behind the title. This snippet gives every course in the “Design” category the same cover picture.
add_filter( 'reign_sn_cover_url', function ( $url, $course_id ) { if ( has_term( 'design', 'course-category', $course_id ) ) { return get_stylesheet_directory_uri() . '/images/design-cover.jpg'; } return $url;}, 10, 2 );Put the picture in your child theme at reign-child-theme/images/design-cover.jpg. Change design to the slug of your course category. Courses in other categories keep their own picture.
You’ll know it worked when a design course that uses the Cover layout shows your picture behind its title.
Stop posting passed quizzes to the activity feed
Section titled “Stop posting passed quizzes to the activity feed”By default, the add-on posts to the activity feed when a learner starts a course, finishes it or passes a quiz. You turn each kind on or off in the settings. This snippet shows the filter that can skip a post in code. It skips passed quizzes.
add_filter( 'reign_sensei_activity_text', function ( $html, $type ) { if ( 'quiz_passed' === $type ) { return ''; } return $html;}, 10, 2 );The types are enrolled, course_done, lesson_done, quiz_passed and quiz_failed. Return changed text instead of an empty string to reword a post.
You’ll know it worked when a learner passes a quiz and no new post about it shows in the activity feed.
Change one template: the instructor name on course cards
Section titled “Change one template: the instructor name on course cards”Cards in the Sensei Course List block show the instructor’s name under the card. This override changes “Priya Sharma” to “Taught by Priya Sharma”. Use the same steps for any file in the add-on’s templates/ folder.
-
Copy
reign-sensei-addon/templates/card/course-card-parts.php. -
Paste it into your child theme at
reign-child-theme/sensei/reign/card/course-card-parts.php. Create thesensei,reignandcardfolders if they are missing. -
In your copy, find this text.
<?php echo esc_html( $parts['instructor'] ); ?> -
Replace it with this text.
<?php echo esc_html( sprintf( __( 'Taught by %s', 'reign-child' ), $parts['instructor'] ) ); ?> -
Save the file.
You’ll know it worked when every card in a Course List block reads “Taught by” before the instructor’s name.
Keep the @version 2.0.0 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.
Good to know
Section titled “Good to know”My snippet broke the site. What do I do?
Section titled “My snippet broke the site. What do I do?”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.
Can I use a code snippets plugin instead?
Section titled “Can I use a code snippets plugin instead?”Yes. The PHP snippets work the same in a snippets plugin. The template recipe needs the child theme, because it is a file.
Where do I find more hooks?
Section titled “Where do I find more hooks?”Every hook the add-on offers is in Hooks and filters.

