Last active
September 25, 2019 10:18
-
-
Save danjjohnson/3be69ac1ba29f22a1498 to your computer and use it in GitHub Desktop.
Sensei - Display lessons on course page only for registered users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
} | |
} |
Updated to also work with modules
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to work with Sensei 1.9+