Skip to content

Instantly share code, notes, and snippets.

@grayayer
Forked from mikeyarce/restrict.php
Last active October 5, 2016 17:55
Show Gist options
  • Save grayayer/f853dfc42be776e6528a6f3d24f6c15b to your computer and use it in GitHub Desktop.
Save grayayer/f853dfc42be776e6528a6f3d24f6c15b to your computer and use it in GitHub Desktop.
WooCommerce Memberships restriction on a page through using a template. This is how we can easily do it for pages that aren't generated through a post, like the Events Calendar archive
<?php
$user_id = get_current_user_id();
if ( wc_memberships_is_user_active_member( $user_id, 'gold' ) ) {
get_template_part( 'template', 'gold' );
} else {
echo "You are not allowed to view this content";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment