I want it kind of like the password protect looks with everything there but it just telling you tht you have to log in or register to view.
No need plugin. Password Protect This Post, see: http://codex.wordpress.org/Writing_Posts
Thanks, but I know of the password protect posts. What I am looking for is something that will tell users to log in or register to view the content of the post. I’ve seen this on other blogs in the past.
Try this:
function somefunction($content) {
if ( !is_user_logged_in() )
echo "...put something here if not logged in";
else
return $content;
}
add_filter('the_content', 'somefunction');
Okay where do I put that at?
Your theme’s functions.php.
btw, have you tried searching in Extend/Plugins?
Member access is what you are looking for.
Member access
Thank you both! I think member access is what I’m looking for. One question, for member access, how do I make the settings for a post to show the title but say “You must be logged in to view the content?”
If I’m logged out the post just doesn’t show at all. I want the title to show just not the content. I want people that visit my blog to want to register or log in to read the post and comment. So how do I do that with the settings?
I just need to know what code to put in the index.php of my theme to allow non registered users to view the title but be required to log in to view the content of the post. I just tried this off the plug-in site and it’s didn’t work
<?php if (have_posts()): while (have_posts()): the_post() ?>
<?php if (function_exists(member_access_is_private)
&& member_access_is_private(get_the_ID())): ?>
<div class="members-only">
<?endif;?>
<h1 class="post_title"></h1>
<?php the_content(); ?>
<?php if (function_exists(member_access_is_private)
&& member_access_is_private(get_the_ID())): ?>
</div>
<?endif;?>
<?php endwhile; endif; ?>
wrap the plugin function around the_content only.
if ....
the_content();
endif
That’s not working either = /
“You can use this tag in your templates to add custom styles to posts that are not available to the general public.”
errr… i think u need to add some CSS to class members-only. e.g .members-only { display: none }
Correct me if I’m wrong. Lazy to browse to code since it’s tooooo long.
Or, you can try this with plugin enabled, modify according to your template:
<?php if (have_posts()): while (have_posts()): the_post() ?>
<h1 class="post_title"><?php the_title(); ?></h1>
<?php if (function_exists(member_access_is_private)
&& member_access_is_private(get_the_ID())): ?>
<?php the_content(); ?>
<?endif;?>
<?php endwhile; endif; ?>
It’s still not working. When I log in I can see the post since I only allow members to see it, but when I log out it disappears. I would still like the post to be there like the title,but for the content to say you have to be logged in or registered to view this post. And it’s not saying that. it just disappears all together.
Thanks for all your help, I decided to keep it the way that it is. Thanks again!