Page 1 of 1

Hiding Posts for non Members

PostPosted: April 2nd, 2011, 1:12 pm
by jl0810
Im sure there is an easy answer here..

I want to use one single home page for my blog posts
* Non members would see probably just one post - like welcome to my site, please register
* Members would see ALL posts


So for non members i don't even want them to see the post snippets


Tried categories, private posts, etc...nothing works so far
Ideas?

Re: Hiding Posts for non Members

PostPosted: April 2nd, 2011, 1:30 pm
by Cristián Lávaque
You could probably edit the homepage's template to display the message for non-members, or the posts for members, depending on their access level using s2Member's conditionals WP Admin -> s2Member -> API / Scripting -> Using Advanced Conditionals and maybe Advanced Query Conditionals.

Re: Hiding Posts for non Members

PostPosted: April 2nd, 2011, 1:46 pm
by jl0810
thanks for the lead - if anyone has done this let me know - would love to steal a snippet of code or something

Re: Hiding Posts for non Members

PostPosted: April 2nd, 2011, 2:08 pm
by Cristián Lávaque
It'd be quite simple, really, because you don't even have to check what access level they have, only if they are a member or not, so checking if they're logged in would be enough.

Code: Select all
if (is_user_logged_in())
{
    
// Show the posts. Use the code in the template to do this.
}
else
{
    
// Give message for non-members.

Re: Hiding Posts for non Members

PostPosted: April 2nd, 2011, 4:54 pm
by jl0810
ok - got it -now another question - use php execution I know how I can add php to a page - but what about the homepage (i'm using the default one)

Re: Hiding Posts for non Members

PostPosted: April 2nd, 2011, 5:04 pm
by Cristián Lávaque
If you're editing the template file, you are in a PHP file already, you don't need a plugin for that. ;)