Skip to content

Instantly share code, notes, and snippets.

@msaari
Last active September 2, 2016 05:21
Show Gist options
  • Save msaari/eeb04acc32d089d3299c89e42e961178 to your computer and use it in GitHub Desktop.
Save msaari/eeb04acc32d089d3299c89e42e961178 to your computer and use it in GitHub Desktop.
Zippy Courses permissions for Relevanssi
add_filter('relevanssi_post_ok', 'zc_user_can_access_page', 10, 2);
// Return a Boolead of if a logged in user can access a page
function zc_user_can_access_page($post_ok, $page_id)
{
// If Zippy Courses isn't on this site, skip this check
if (!class_exists('Zippy')) {
return $post_ok;
}
$zippy = Zippy::instance();
// Get the student access middleware
$middleware = $zippy->middleware->get('student-access');
$result = $middleware->run($page_id);
if ($result) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment