th3n33ms
Member
Posted 6 years ago #
Hey guys,
I was wondering how I would go about adding a script or some kind of thing to my sidebar so that it checks whether you are logged in or not, and if you are it shows an alternate menu of sorts.
Currently I have an admin login on the sidebar, I would like the sidebar to check to see if you are logged in, if you are it shows a bunch of admin related links and stuff, but if not it keeps showing the login.
Can anybody help me with this?
Thanks
Try this
'
global $user_ID
if('' == $user_ID) { echo "you are logged out" } else { echo "you are logged in"}
'
vistasucks
Member
Posted 6 years ago #
Could this be used to limit sidebar widget visibility to those that are not registered and logged in?
eg: if user is not logged in, they can't see the category listing box, recent comments box, text boxes, etc.?
Where exactly would that code be placed? (Kinda vague to a newbie.)
doesnt this show whether you are logged in or out?
<?php wp_loginout(); ?>
maybe indirectly i suppose, it says login or logout, and surely from that you can work out if your logged in. it is even a link so you can login/logout...
vistasucks
Member
Posted 6 years ago #
I'm a php newb. I barely followed that. But it sounds like you don't know either?
ok, ill rephrase it...
<?php wp_loginout(); ?>
shows logout if you are logged in, and is a clickable link to logout, so you must be logged in.
and shows login if you are logged out, and is a clickable link to login, so you must be logged out.
But it was answering the OP.
But Kadtesgasis post could be adapted to do what you want vistasucks. With the use of some if statements.
vistasucks
Member
Posted 6 years ago #
But Kadtesgasis post could be adapted to do what you want vistasucks. With the use of some if statements.
I read the page you linked to in your post. But wouldn't there need to be a:
if is_logged_in()
or something similiar?
vistasucks
Member
Posted 6 years ago #
vistasucks
Member
Posted 6 years ago #
vistasucks
Member
Posted 6 years ago #
In another topic where you posted they've found the solution...
http://wordpress.org/support/topic/117787?replies=5
vistasucks
Member
Posted 6 years ago #