Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save actual-saurabh/673559f949396e33d28efcfe3f634456 to your computer and use it in GitHub Desktop.
Save actual-saurabh/673559f949396e33d28efcfe3f634456 to your computer and use it in GitHub Desktop.
Extend membership restriction to courses, memberships and other post types
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_filter( 'llms_membership_restricted_post_types', 'my_membership_restriction_post_types' );
/**
* Add LifterLMS membership restrictions to a custom post type
* @param array $post_types array of custom post types
* @return array
*/
function my_membership_restriction_post_types( $default_post_types ) {
$post_types_to_restrict = ('llms_membership', 'course', 'event', 'another_post_type');
$updated_post_types = array_merge( $default_post_types, $post_types_to_restrict );
return $updated_post_types;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment