Sensei: Messages: Add ability to customize notices/messages

Created on 25 Oct 2017  路  6Comments  路  Source: Automattic/sensei

I'm using Sensei for creating courses that are video tutorials - the lessons are not graded and are not pass/fail... So when a user completes the lesson, I don't want the message to say "Congratulations! You have passed this lesson". They haven't "passed" anything, they just watched the video tutorial, and may want to watch it again. I couldn't find a way to customize the text for things like this, though. Am I missing something?

All 6 comments

@Protohominid You can do this using the sensei_user_quiz_status filter. Hopefully you are using a child theme already, and can just drop code similar to the following in functions.php:

function set_lesson_complete_text( $args ) {
  if ( $args['status'] === 'passed' ) {
        $args['message'] = 'You've watched this video.';
  }

  return $args;
}

add_filter( 'sensei_user_quiz_status', 'set_lesson_complete_text' );

Hope that helps!

That's it, thanks! The name of that filter is misleading... I never would have guessed it controlled the message on a lesson page (I'm not using quizzes at all).

Is there a list of filters like this with an explanation of what exactly they do somewhere?

Yes and no. We have a list of hooks and filters here, but they don't have explanations. Not ideal, I know. 馃檨 We'll need to take a look at revamping these docs.

Yeah, I don't see a list of filters there either. What was your method for finding the relevant filter and action hook above? Maybe if I know your process I can find others on my own. :-)

For example, I'd like to change the URL that this message links to: "Please purchase the course before starting the lesson." That message shows on a lesson page when you don't have access to that course. I'd rather have that link to the product page instead of the Sensei course page.

Apologies. Looks like I linked the wrong page. Actions and filters are here - https://docs.woocommerce.com/sensei-apidocs/hook-docs.html.

To find the previous filter, I searched the Sensei codebase for a portion of the text, and then traced the flow from there to locate the relevant filter.

That's the way I've been trying to find filters and hooks as well, so that's good to know.

Thanks again for your help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cleardesign picture cleardesign  路  5Comments

richardmtl picture richardmtl  路  7Comments

merkushin picture merkushin  路  3Comments

cycomarcooo picture cycomarcooo  路  5Comments

MindyPostoff picture MindyPostoff  路  3Comments