Skip to content

Instantly share code, notes, and snippets.

@leftlane
Created August 1, 2017 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leftlane/0e7514dc8b40861d4051ce170c8638bd to your computer and use it in GitHub Desktop.
Save leftlane/0e7514dc8b40861d4051ce170c8638bd to your computer and use it in GitHub Desktop.
Custom function to pull in the video on a lesson page on WP101.com
function lesson_get_video_tutorial() {
if ( 'lesson' === get_post_type() ) {
$lesson = new LLMS_Lesson( get_the_ID() );
$display = false;
if ( $lesson->is_free() ) {
$display = true;
} else {
$display = llms_is_user_enrolled( get_current_user_id(), get_the_ID() );
}
echo '<div class="wrap video-wrap">';
if ( $display ) {
echo $lesson->get_video();
} else {
echo '<a href="/membership/" title="Sign up to view this WordPress tutorial video"><img src="/wp-content/uploads/2014/03/non-member.jpg" alt="WordPress Tutorial: ' . the_title_attribute( array( 'echo' => 0 ) ) . '" width="1280" height="720" border="0" /></a>';
}
echo '</div>';
remove_action('lifterlms_single_lesson_before_summary', 'lifterlms_template_single_lesson_video', 20 );
}
}
add_action( 'genesis_after_header', 'lesson_get_video_tutorial' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment