I too need to hide stuff. I would rather wordpress’ login keep out the unregistered / unapproved users than my current method of password protecting the wp installation directory. I’m using a plug-in right now that keeps posts hidden when not logged in (which works fine) But I need the sidebar contents to remain hidden as well.
Thread Starter
Kahil
(@kahil)
Yeah, it seems as though all the plugins out there only hide things within the content div… I can’t figure out how to mod them so that the other areas like the header and sidebar do the same. 🙁
Not a plugin, just some basic code:
http://wordpress.org/support/topic/92378?replies=4
It should get you started: change the level of the user and change what is displayed for logged in or else…
Thread Starter
Kahil
(@kahil)
Thank you!!!! Took me a few minutes to figure it all out correctly, but it works!!!
Someone should make a plugin out of all that.
I agree someone should make a plugin.
I’m a total php newb and am reading instructions that assume a certain level of knowledge.
Can someone talk me through adding this code?
Thread Starter
Kahil
(@kahil)
What are you wanting to do? Give us an example cuz it can be a lil tricky getting certain thing to display correctly. I found that out after some trial and error with links and images, etc.
I want to keep both posts and sidebar widget contents invisible until the user is logged in. Thus preventing unauthorized viewing of sensitive info. Currently the WP installation dir is pw protected but would rather it be WP’s login that protects the site’s contents.
My category’s posts are already protected via a plugin but I don’t want the sidebar contents (comments, category names etc.) to be visible either.
Thread Starter
Kahil
(@kahil)
<?
get_currentuserinfo() ;
global $user_level;
if ($user_level > 0) {
echo “yes”;
} else {
no
}
?>
Well, everything you want people to NOT be able to see will go in where yes is. Just remember that whatever code you put in there, you replace all the ” with ‘
anything you want them to see goes where no is
Thanks Kahil. But can you tell me which .php file in which directory that code goes into? Is it the index.php or the sidebar.php in my chosen theme folder?
Am I understanding right that the line would be something like:
echo "sidebar";
or
echo "categories";
with ‘ where the ” are?
I tried adding the above code into index.php in my theme folder in between
<?php get_sidebar(); ?>
and
<?php get_footer(); ?>
I tried modifying
echo "yes";
into
echo "sidebar";
and
echo "sidebar.php";
but that gave me errors. What am I doing wrong?
Thread Starter
Kahil
(@kahil)
don’t know how it’ll work or turn out by doing what you are trying to do… it just sounds like there is a better way to do all that, but ok…
use get_sidebar();
Please just spell it out for me!!!
This is what I have (based on my understanding of what you’ve told me.)
index.php :
<?php get_sidebar(); ?>
<!-- This is my test code to keep the sidebar hidden unless use is logged in. -->
<?
get_currentuserinfo() ;
global $user_level;
if ($user_level > 0) {
echo "use get_sidebar();";
} else {
no
}
?>
<!-- This is my test code to keep the sidebar hidden unless use is logged in. -->
<?php get_footer(); ?>
Thread Starter
Kahil
(@kahil)
Try this…
<?
get_currentuserinfo() ;
global $user_level;
if ($user_level > 0) {
echo "get_sidebar();";
} else {
no
}
?>
This is not working. Clearly we have some kind of communication problem.
Thread Starter
Kahil
(@kahil)
I don’t know why it isn’t working for you, it worked great for me.
Why don’t you just have a different page using a template that doesn’t call the sidebar or footer, etc. Set that as your homepage. Then use the Login Anywhere plugin on it so that for them to continue they have to login