Last active
September 2, 2016 05:21
-
-
Save msaari/eeb04acc32d089d3299c89e42e961178 to your computer and use it in GitHub Desktop.
Zippy Courses permissions for Relevanssi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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