Level ID for Visitors
-
Hi Simple,
I found this redirect if the visitors have NO permission.
Anyhow, I already set the Level ID and protected the page content. What I have already set is FREE = 2 and GOLD = 3
So, is there’s level ID just for the visitors by default? Perhaps, what’s the best way to set ID for the visitors?
————————————————–* Check Current User’s Post Access Permission then Redirect User
The following example code checks if the current user has access to the post being viewed then redirects the user if he/she doesn’t have access to it.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;
}————————–
I try to think a way? But I’m not hitting it LOLPlease advise help,
Thanks
-
Hi, I am not following what you are trying to achieve. Can you provide a step by step example.
Thank you
Hi Simple,
I was confused myself too when I wrote this. LOL Ok, let’s make it easy for both 🙂
Let’s say you go to my site on any page (homepage, post,page), you have NO permission to view the contents? What page will you end up on, 404.php?
So what is that functions for anyway?
Hope you understand this time, perhaps me?
Please advise,
ThanksHi,
Let’s say you go to my site on any page (homepage, post,page), you have NO permission to view the contents? What page will you end up on, 404.php?
Are you talking about the page you will be redirected too after you register within a page or post that you can’t view the content because you have no permission?
So what is that functions for anyway?
What function are you talking about?
Kind regards
Hi Simple,
Yes, you can’t view the content because you have no permission?
********************************
And whatever this what I pasted here is for? I found this from the documentation.
Like this //This user doesn’t have permission to see this post. Redirect the user.
$redirect_url = ‘http://example.com/redirect-page’;
wp_redirect($redirect_url);SEE BELOW HERE
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;
}Please advise help,
Thanks-
This reply was modified 7 years, 6 months ago by
junglejim620.
Hi simple,
I found my answer. However it DOESN’T work when I put it in the theme functions.php?
This is the link where I found it. https://simple-membership-plugin.com/?s=wp_redirect
Auto Redirect Non Logged-in Users (Protect Whole Site)
/*** Auto redirect a user who isn’t logged into the site ***/
add_filter( ‘pre_get_posts’, ‘swpm_auto_redirect_non_members’ );
function swpm_auto_redirect_non_members() {
if( !SwpmMemberUtils::is_member_logged_in() && !is_page( array( ‘membership-login’, ‘membership-join’ )) ) {
wp_redirect( ‘http://www.IalreadyChangedHere.com/membership-login’ );
exit;
}
}Please advise help,
Thanks
Hi Simple,
I Got it going…
Thanks
Hi, I am happy to know that you worked it out 🙂
Just out of curiosity, what did you do to fix your issue?
Thank you
Hi Simple,
Sure, Since I will be using this simple membership and full protection plugin. I want to stick with your functions for this reason. So to be compatible together.
I already have 2 -3 redirects in the functions, so too many redirects. I disabled the 2 for testing. One is actual for my previous membership plugin, and one is buddypress register.php Now it’s all good..
Thanks,
-
This reply was modified 7 years, 6 months ago by
The topic ‘Level ID for Visitors’ is closed to new replies.