Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kimcoleman/087e7bc3470fdee1a319d44804a8212e to your computer and use it in GitHub Desktop.
Save kimcoleman/087e7bc3470fdee1a319d44804a8212e to your computer and use it in GitHub Desktop.
Redirects members-only content to the Membership Levels page on the Main Network Site if a user is logged out or not a member.
<?php
/*
* Redirects members-only content to the Membership Levels page on the Main Network Site
* if a user is logged out or not a member.
*/
function my_template_redirect_network_require_membership_access() {
if ( ! pmpro_has_membership_access() ) {
wp_redirect( network_site_url( 'levels' ) );
exit;
}
}
add_action( 'template_redirect', 'my_template_redirect_network_require_membership_access' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment