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

eMember – Protecting content outside a post (custom fields and shortcodes)

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › eMember – Protecting content outside a post (custom fields and shortcodes)

Tagged: custom fields, shortcode

  • This topic has 5 replies, 3 voices, and was last updated 12 years, 4 months ago by admin.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • December 28, 2012 at 6:24 am #8225
    JuryDuty
    Member

    I’m building a video teaching site and have the challenge that my theme uses a custom field to display the video at the top of the page. eMember doesn’t block this video since it’s located outside of the post area.

    Here’s an example: [http://www.writingmomentum.com/vibrant/]

    Is there some php code I could put around the video that would protect it? The shortcode doesn’t seem to work in the custom fields.

    Or, is there code I could use for sitewide protection that sends anyone without access to the Sign Up page? The Sitewide Protection included in the settings is good, but it makes me include or exclude EVERY url which is daunting as every time I add a blog post, I’d have to exclude it here.

    Thank you!

    (Just read rule #3: Please understand I’m not asking for custom code help–I just thought this member solution could block access to an entire page…but it’s really only blocking access to the post itself, not what’s around it. I’m hoping there’s a work

    around for that. Thanks for your help!)

    December 28, 2012 at 4:28 pm #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 ?>

    December 28, 2012 at 8:55 pm #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 10:21 pm #52660
    Peter
    Member

    Hi

    Regarding protecting the section you are referring to based on membership levels, see the section in the following page called “Show Different Menus to Different Membership Levels” which might be what you’re looking for:

    http://www.tipsandtricks-hq.com/wordpress-membership/show-different-navigation-menu-to-your-members-and-non-members-551

    December 28, 2012 at 10:27 pm #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 10:49 pm #52662
    admin
    Keymaster

    The example in the following post should help (it shows you how to find out if the post or page is accessible for the member in question:

    https://support.tipsandtricks-hq.com/forums/topic/bbpress-forums-lockdown/page/2

    The following documentation is also a good reference:

    http://www.tipsandtricks-hq.com/wordpress-membership/wp-emember-miscellaneous-tweaks-248

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Log In

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