Last active
September 2, 2016 22:32
-
-
Save thomasplevy/7ab5f2e74906c55201260791d890d6de to your computer and use it in GitHub Desktop.
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
/** | |
* Redirect restrictions to a custom URL | |
* @param array $results array or result info | |
* @return void | |
*/ | |
function my_llms_page_restrictions( $results ) { | |
// url to redirect to when user does nt have access | |
$redirect_url = 'http://mycustomredirect.url'; | |
if ( $results['is_restricted'] ) { | |
$user_id = get_current_user_id(); | |
// check access | |
$access = ( $user_id ) ? llms_is_user_enrolled( $user_id, $results['post_id'] ) : false; | |
// redirect if use is not logged in or does not have access | |
if ( ! $access ) { | |
wp_redirect( $redirect_url ); | |
exit; | |
} | |
} | |
return $results; | |
} | |
add_filter( 'llms_page_restricted', 'my_llms_page_restrictions' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment