Some Comments on Woo Sensei

I frequently get asked to work on Woo products. For awhile it was modifying their WordPress themes, and then Woo Commerce. Now their business has strongly shifted from themes to plugins. Their plugins generally work fine, but with countless customers, there will always be some who need some additional help. In my travels, the changes people want tend to fall into these categories, in increasing order of difficulty:

  • Appearance changes to match the theme they are using.
  • Structural changes in pages that show Woo output.
  • Programming and functionality changes.
Their theme seems to be Plugging In.
Their Theme: Plug-Ins.

Note: the following procedure requires some file editing, file transfers, a willingness to edit some code, some WordPress skills, and a general understanding of how a webpage is constructed. If that gives you the heebie jeebies, get help from a developer.

I’ve had a number of requests to work on Sensei, their plugin for putting online courses onto your site. Most were for appearance changes, but my design colleague and tutorial expert Rob Cubbon wanted to have some user interaction on his lesson pages. In the WordPress backend, if you go to Sensei… Settings, and click on Lessons at the top, you’ll see this setting: Allow Comments for Lessons

That should be ticked/checked, and it was on his site. So far everything looked fine. He and some users had made some comments, which were visible in the WordPress back end, but the problem was that they weren’t displaying on the lesson pages!

Doc – What’s Up?

Then this helpful bit of Woo Sensei theming documentation came in handy (look for “Single Lesson”).  I could have worked it out by hunting through code, but this saved time. I have to credit Woo with having pretty nice documentation. Many theme companies, including some with nicely-coded themes, have sucky documentation.

Warning: the following procedure requires some web development skills. Unless you’re very comfortable editing theme PHP code, hire a developer to do this!

That reminds me of another project – I was working with a very pretty commercial theme one time, and the client wanted significant changes. I asked the theme company if they had included any programming hooks or filters, and their bafflement made it seem like I had asked them to go fishing and smoking. They went off my recommended companies list, stat.

No Comment

I thought of the following obvious WordPress template bit of code for comments, but that didn’t do anything when I popped it in for a test.


I suppose I should have expected that, given that the form had appeared before, and some comments were entered but just didn’t display.

Sensei’s Martial Plan

Though some pretty good documentation exists for Sensei theming, for some reason they removed the part that explains how to safely make changes to Sensei templates. Weird! Fortunately, I had learned that the plugin’s templates were helpfully contained in the /templates folder in the Sensei plugin. I also knew that these plugin templates could be edited safely by putting a copy into my child theme, thus not changing core plugin code, so I made a copy of /templates/single-lesson.php, edited it, and put it into my child theme’s /sensei folder. This is a very handy way to allow a safe code override, and I applaud any plugin developer who allows that!

Because the normal comments template code didn’t do anything, I assembled a more manual method of displaying comments instead:

The above code should be pasted into single-lesson.php (in your child theme as per above)  just before this line:

do_action( 'sensei_single_main_content' );

The comments immediately showed up! On this theme, my new markup looked pretty bare, so I added a pinch of styling for it. Obviously the CSS context of your theme will vary, but I hope this gives you an idea of what can be done. Here’s one of the places where this is working on Rob’s lesson site.

Turn It On Again With Genesis

My client’s theme was a Genesis theme, so there may have been some incompatibility with its own comment code. I may tear apart more code to find the root cause of this, especially if anyone expresses a strong interest.

This dapper fellow was heard yelling “Woo!!!”

One Singular Silenced Sensei-tion

I was asked to work on a site using “One”, yet another popular & enormous Themeforest theme. My client had implemented my suggestion above, which had produced a whole bunch of crummy looking output. (Doh!) Taking a close look, it turns out that the existing comments were appearing twice, and the second bunch had no CSS styling. So instead of no comments at all, the comments themselves were cloned, yet the comment response form was missing!

Now that’s not very sociable! So I went about looking for the reason. In many WordPress themes, a theme geek can find lots of clues in the theme’s files. In most child themes, if you want to change some behavior of the parent theme, you can safely do that by copying parent theme files to the child theme and modifying them. This theme objected to that, crashing impressively. As I recall, the duplicate file had some hard-coded includes that bombed when executed from the child theme folder. I also found a huge code framework in the parent theme. I’m sure this helps the original developers, although it hinders people trying to modify the theme (possibly by design).

I know, I’ve just lost many of you. 🙂  In English, this means that the One theme code is not trivial to modify, even for a theme geek.

After pawing through reams of code, I finally found a way in. Using a different Sensei programming hook, I managed to slip in the comment form like so:

Just like the code further above, this will go into your copy of single-lesson.php that you’ve put into your child theme, just before the line that says:

do_action( 'sensei_single_main_content' );

But Wait, There’s More – A Private Message

There’s one more area where the comment form was missing from “One” but was desired… this was the screen where the teacher is responding to a student’s private message. I tracked that down to another Sensei template file, content-single-message.php. Since this file does not seem to appear on Woo’s documentation site, instead of publishing the contents of the file, I’ll just say that you want to include the following line in your copied template file, just after the line that contains “the_content”.

Alert readers trying this will notice that the comment form appears above the existing comments instead of below (the normal way). This is a restriction due to One’s custom template structure. Anyone wanting to hack One to get it below existing comments can certainly try that, although that’s even more work, and may possibly void your “One” theme support or botch upgrades they have if you edit their core code. Or just keep harassing the “One” developers until they help. 🙂

Props go to Vitruvian Studio. Check them out for a variety of courses in drawing, painting, and other art topics, both online and in their Chicago area location!

I certainly haven’t tested my ideas above in every theme out there, but I think my code could be useful for various themes that are also shy about showing Sensei comments. Please let me know how you make out in the comments below!



  1. Great fix. As an alternative approach, try placing the following at the bottom of content-single-message.php (after copying to your theme’s /sensei directory, of course):



  2. Greg,
    Great idea, a very clean approach for Genesis users!

    My method is more work, but should offer similar functionality for non-Genesis folks.



  3. This issue also applies to personal messages, but with a twist: both of our solutions cause message replies to be visible to anyone accessing the page! After some research, I’ve come up with a fix, but would love it if you could take a look at the code.

    The source of this issue is that Sensei outputs comments on lessons and messages by calling comments_template(), while Genesis uses its own genesis_get_comments_template(). Sensei also provides some validation code to ensure that comments are only visible to the sender and recipient. So here’s what I dropped into functions.php to get it done:

    //* Add "Back to My Messages" link on single message pages.
    function pasada_messages_link() {
    if ( is_singular( 'sensei_message' ) )
    echo ' Back to My Messages';
    add_action( 'sensei_single_main_content', 'pasada_messages_link' );

    //* Show comments on Sensei lessons and messages.
    function pasada_sensei_genesis_comments() {
    global $woothemes_sensei, $view_lesson, $user_taking_course;
    $allow_comments = $woothemes_sensei->settings->settings[ 'lesson_comments' ];
    if ( is_user_logged_in() && $allow_comments && ( isset( $view_lesson ) && $view_lesson ) && ( isset( $user_taking_course ) && $user_taking_course ) ) {
    genesis_get_comments_template(); // Add Genesis comments template.
    } elseif( is_singular( 'sensei_message' ) ) {
    genesis_get_comments_template(); // Add Genesis comments template.
    add_filter( 'sensei_comments', 'pasada_sensei_genesis_comments' );

    //* Remove and restore the comment form (removes duplicate forms on Sensei lessons and messages).
    function pasada_move_comment_form () {
    if ( is_single() ) {
    if ( have_comments() ) {
    remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
    add_action( 'genesis_list_comments', 'genesis_do_comment_form' , 10 );
    add_action( 'genesis_before_comments' , 'pasada_move_comment_form' );

    //* Modify comments title text based on context.
    function pasada_genesis_title_comments() {
    if( is_singular( 'sensei_message' ) ) { // Hide comment title on Sensei messages.
    $title = '';

    return $title;
    } elseif( is_singular( 'lesson' ) ) { // Rename comments title on lesson pages.
    $title = 'Discussion';

    return $title;
    } else { // Rename comments title everywhere else.
    $title = 'Comments';

    return $title;
    add_filter( 'genesis_title_comments', 'pasada_genesis_title_comments' );


  4. Greg,
    That’s a very intriguing idea. I had indeed been asked to have the comments visible to everyone, as this helped everyone interact and learn more from each other, so I don’t think I would typically need this function, and frankly, I don’t have time to test it right now.

    If I do ever run into this need, I will very likely give your code a test.



  5. Great fix. I ve tested with Divi Template and works fine. Thanks for sharing it.

    Best, Javier


  6. Javier,
    Me alegro…. you’re welcome.

    Saludos, Dave


    1. Greg,
      Classy idea. 😉

      Thanks! Dave


  7. Hi Greg, Hi Dave.
    Could you give me advice with displaying comments in lessons which have the option Lesson Preview is enable?
    In base configuration the comments are displaying only for administrator or for login user, who is taken the course.
    I have many free lessons without including in courses (lesson course option is none) and I want that visitors can post the comment without login and taking course. What template i should correct for this?
    Thanks, Dmitry


    1. Dimitry,
      I imagine it’s doable, but without doing a code investigation, I don’t know. So solving that would be a paid job for me, I’m afraid.



    2. Hi Dimitry,

      If you examine the gist I provided in a previous comment, you’ll notice some logic to display comments only to authenticated users. You can adjust this IF statement to fit your specific use case, or even better you could hire the amazing Dave to take care of it for you. 🙂



      1. Excellent point! Or hire Greg. 🙂


  8. This is great… and has got me sooooo close to having comments appear on the sensei lesson pages. I’m using a theme by Oceanthemes called “Learn” which claims it is specially for sensei!

    Anyhow, does anyone know how to get the comments showing below the lesson rather than above it?

    Additionally whenever I copy the single-lesson.php template from Sensei into my child theme for editing, I seem to lose the sidebar on the lesson.

    I know this may be to do with the theme but “Oceanthemes” support are not being massively responsive or helpful so seeing if anyone else has any bright ideas.



    1. Howard, If none of the examples work, I’m afraid this is most likely one of those things where you have to examine the theme code to know where to put it.
      Detective work needed.



  9. Fascinating post.
    I am running Sensei 1.9.9 and in single-lesson.php there is no: do_action( ‘sensei_single_main_content’ );

    There is this though:
    do_action( ‘sensei_single_lesson_content_inside_before’, get_the_ID() );

    see below for the whole file

    <article >

    ID ) == ‘top’ ) {

    do_action( ‘sensei_lesson_video’, $post->ID );



    } else {

    frontend->sensei_breadcrumb – 30


    1. Marjan, I’ll take your word for it. 🙂

      I don’t keep an eye on each Sensei version. Because I’m busy with lots of things, I only work on it when requested, so my stuff above may indeed become out-of-date, or may possibly be newer than some installations.



      1. Haha, should I have been clearer ?
        Help! I have no clue what to do. ..




        1. Marjan, Just showing a bit of code tells me nothing, so sorry, this is something you’ll have to get someone to investigate directly, in other words, hiring someone.

          Sorry, Dave


Leave a Reply

Your email address will not be published. Required fields are marked *