Skip to content

Instantly share code, notes, and snippets.

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 strangerstudios/6b1da218e5fad3baee9f to your computer and use it in GitHub Desktop.
Save strangerstudios/6b1da218e5fad3baee9f to your computer and use it in GitHub Desktop.
Restrict access to certain pages based on a user meta value.
/*
Users with the upsell usermeta have access to everything.
*/
function my_pmpro_has_membership_access_filter($hasaccess, $mypost, $myuser, $post_membership_levels)
{
$upsell = $myuser->upsell;
if(!empty($upsell))
{
//could also check that $mypost is a specific page or in a specific group of pages here
$hasaccess = true;
}
return $hasaccess;
}
add_filter('pmpro_has_membership_access_filter', 'my_pmpro_has_membership_access_filter', 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment