Forum Replies Created
-
AuthorPosts
-
JuryDutyMember
I’m trying to do a similar thing. I want to check and see if a user is the appropriate level for a post and if not, instead of prompting them to login, I want to redirect them to a sign-up page immediately.
I think I can modify your code above to do this, but it’s not working quite right. Here’s what I put at the top of my single.php file, above everything:
<?php
function eMember_redirect_instead_of_hide() {
$emember_auth = Emember_Auth::getInstance();
$is_protected = false;
if($is_protected){
header(‘Location: http://www.google.com’);
// Obviously I’ll change google to be a meaningful page later–this is just for testing.
exit();
}
} ?>
Then in my functions.php file, I put this at the top:
add_action(‘eMember_redirect_instead_of_hide’);
I’m sure this isn’t right as it’s not working, but I think I’m close…can you (or anyone) help?
December 28, 2012 at 10:27 pm in reply to: eMember – Protecting content outside a post (custom fields and shortcodes) #52661JuryDutyMemberThat’s close–it’s differentiating between member/non-member, OR it’s allowing you to hard-code levels in. But what I need is for the code to check and see if the user–depending on their level–has access to the post on the page. We’re almost there, but I need it to dynamically match the post level with the user level rather than hard-coding it in.
I’m sure this is possible, as that’s what’s happening within the post itself. I just need to bring it out of the post and make it apply to other elements surrounding it.
Any other thoughts?
December 28, 2012 at 8:55 pm in reply to: eMember – Protecting content outside a post (custom fields and shortcodes) #52659JuryDutyMemberSo while waiting for an answer, I’ve continued to dig and found that if I use this code…
<?php
global $auth;
$user_id = $auth-?>getUserInfo(‘member_id’);
if (!empty($user_id))
{
echo “This secret message is for member’s only”;
echo “Any content here can only be viewed by members”;
}
?>
…or this code…
<?php if(wp_emember_is_member_logged_in()) { ?>
//Place your special message for members here
<?php } ?>
…I can show or hide the content based on whether they’re a member or not. So we’re almost there. It’s just too broad as members could be various levels.
All I need to add to that is the ability for it to show or hide the content based on if they have access to this particular post.
What I don’t want to do is hard-code in items for each level, because I need it to adjust over time based on new levels I add, etc. Make sense?
December 28, 2012 at 4:28 pm in reply to: eMember – Protecting content outside a post (custom fields and shortcodes) #52658JuryDutyMemberJust to clarify, what would work best is something like this:
<?php CHECK TO SEE IF MEMBER HAS ACCESS TO THIS POST. IF SO ?>
DISPLAY VIDEO
<?php IF NOT ?>
DISPLAY ALTERNATE IMAGE
<?php ?>
-
AuthorPosts