Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thomasplevy/7a80d04575eb829258cbead344d5a630 to your computer and use it in GitHub Desktop.
<?php // don't copy this line to your functions.php file
/**
* Ahh a post type to the list of post types LifterLMS will NOT check for membership restrictions
* @param array $post_types array of post type names
* @return array
*/
function my_allow_lessons_restrictions( $post_types ) {
array_push( $post_types, 'my_custom_post_type' );
return $post_types;
}
add_filter( 'llms_is_post_restricted_by_membership_skip_post_types', 'my_allow_lessons_restrictions' );
<?php // don't copy this line to your functions.php file
/**
* Remove a post type from the list of post types LifterLMS will NOT check for membership restrictions
* @param array $post_types array of post type names
* @return array
*/
function my_allow_lessons_restrictions( $post_types ) {
// the following post types are automatically bypassed
// during membership restriction checks
// course
// lesson
// llms_quiz
// llms_membership
// llms_question
// llms_certificate
// llms_my_certificate
// this will remove lessons from the list so that lessons can be restricted
$i = array_search( 'lesson', $post_types );
if ( false !== $i ) {
unset( $post_types[ $i ] );
}
return $post_types;
}
add_filter( 'llms_is_post_restricted_by_membership_skip_post_types', 'my_allow_lessons_restrictions' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment