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

Hiding posts rather than requiring login

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember General Questions › Hiding posts rather than requiring login

Tagged: login

  • This topic has 8 replies, 3 voices, and was last updated 12 years, 1 month ago by amin007.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • October 21, 2010 at 3:59 am #2070
    drlidbom
    Member

    I’m looking for a way to not show certain posts at all, rather than display a message that someone must login to view the content. Is there a way not to show posts if a user is not logged in?

    October 21, 2010 at 5:15 am #25651
    amin007
    Participant

    This will have to come from a template (WordPress theme) level as the theme is what lists all the posts in your blog.

    So you should be able to read this post to learn how you can check if a member is logged in or not then add an if condition to where the post gets displayed in the theme:

    How to get member id and his details (retrieve member details)

    Does that make sense?

    October 21, 2010 at 6:18 pm #25652
    drlidbom
    Member

    Yes, but how can I tell if the post is a protected post or not?

    October 22, 2010 at 6:55 am #25653
    amin007
    Participant

    I see… I think if we can add in a function in eMember that takes a post ID and tells you if the post is protected or not may be a solution for this. I will look into it.

    October 22, 2010 at 11:39 am #25654
    drlidbom
    Member

    Thanks…please keep me posted.

    As an aside, there would still be an issue with pagination or number of returned results, because the post query would return x results to loop over and then the user (if they were not logged in) would see x – y posts, where y is the number of protected posts.

    Thoughts?

    October 23, 2010 at 12:47 am #25655
    amin007
    Participant

    This is the code that you can put in your functions.php file and use it to find out if a post is protected or not:

    function eMember_is_post_protected ($post_id)
    {
    global $wpdb;
    $wpdb->prefix . "wp_eMember_membership_tbl";
    $query = "SELECT post_list FROM " . $wpdb->prefix . "wp_eMember_membership_tbl WHERE id = 1;";
    $post_list = unserialize($wpdb->get_var($wpdb->prepare($query)));
    if(!$post_list) return false;
    return in_array($post_id, $post_list);
    }

    Now, you can use the above function like the following (this is just an example):

    if(eMember_is_post_protected ($post->ID))
    echo "Post is protected";
    else
    echo "Post is not protected";

    October 23, 2010 at 12:54 am #25656
    amin007
    Participant

    Yeah the pagination would be an issue. Basically, anything that gets controlled by the theme will have to be controlled on a theme level (this is why eMember doesn’t have options to do anything like this)

    February 11, 2011 at 3:02 pm #25657
    Tuttie
    Member

    I am using http://www.elegantthemes.com/preview/Magnificent/ and would like to do the same. Hide pages and posts and only viewable after login. Also hide the pages that led them to the purchase aka hte squeeze pages.

    February 12, 2011 at 3:40 am #25658
    amin007
    Participant

    You need to apply similar changes that I mentioned in the post above to the theme. I am not familiar with that theme so cannot tell you exactly where to change.

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

Forum Related

  • Forum Home
  • Forum Search
  • 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
  • WP PDF Stamper Documentation
  • WP Photo Seller 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
  • WP Photo Seller Video Tutorial

Our Other Plugins

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

Copyright © 2023 | Tips and Tricks HQ