Skip to content

Instantly share code, notes, and snippets.

@danjjohnson
Last active September 25, 2019 10:18
Show Gist options
  • Save danjjohnson/3be69ac1ba29f22a1498 to your computer and use it in GitHub Desktop.
Save danjjohnson/3be69ac1ba29f22a1498 to your computer and use it in GitHub Desktop.
Sensei - Display lessons on course page only for registered users
add_action( 'sensei_before_main_content', 'sensei_conditional_lesson_display', 10 );
function sensei_conditional_lesson_display() {
if( !is_singular('course') ) return;
global $post, $current_user, $woothemes_sensei;
$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
if ( ! ( $is_user_taking_course || sensei_all_access() ) ) {
remove_action( 'sensei_single_course_content_inside_after' , array( 'Sensei_Course','the_course_lessons_title'), 9 );
remove_action( 'sensei_single_course_content_inside_after', 'course_single_lessons', 10 );
remove_action( 'sensei_single_course_content_inside_after', array( Sensei()->modules, 'load_course_module_content_template' ), 8 );
}
}
@Kellylise
Copy link

Ditto - this no longer works

@danjjohnson
Copy link
Author

Updated to work with Sensei 1.9+

@danjjohnson
Copy link
Author

Updated to also work with modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment