- This topic has 1 reply, 2 voices, and was last updated 8 years, 11 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
WordPress Membership Plugin
Simple Membership Plugin › Forums › Simple Membership Plugin › Redirect to home if person is not logged in or if dont have access
Tagged: redirect
Hi Guys.
Trying to find code for my functions.php file:
if someone is NOT logged in OR does NOT have access to a PAGE, then redirect to my home page.
I did find the code below, but does not work (maybe because it refers to a Post vs Page (not sure it matters?))
global $post;
$post_id = $post->ID;//Grab the post ID
$protection_ctrl = SwpmProtection::get_instance();
//Check if the current visitor has access to this post.
$is_protected = $protection_ctrl->is_protected($post_id);
if($is_protected) {
//This user doesn’t have permission to see this post. Redirect the user.
$redirect_url = ‘http://example.com/redirect-page’;
wp_redirect($redirect_url);
exit;
}
THANK YOU!!
Hi, did you check the following PHP Tweaks?