Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration
You are here: Home

JuryDuty

  • Profile
  • Topics Started
  • Replies Created
  • Engagements
  • Favorites

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • December 28, 2012 at 11:32 pm in reply to: bbPress Forums Lockdown #42876
    JuryDuty
    Member

    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&#8217;);

    // 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) #52661
    JuryDuty
    Member

    That’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) #52659
    JuryDuty
    Member

    So 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) #52658
    JuryDuty
    Member

    Just 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 ?>

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ