WordPress.org

Ready to get started?Download WordPress

Forums

Making a sidebar detect login + show different menu (12 posts)

  1. th3n33ms
    Member
    Posted 8 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

  2. katesgasis
    Member
    Posted 8 years ago #

    Try this
    '
    global $user_ID
    if('' == $user_ID) { echo "you are logged out" } else { echo "you are logged in"}
    '

  3. vistasucks
    Member
    Posted 7 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.)

  4. Alex Cragg
    Member
    Posted 7 years ago #

    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...

  5. vistasucks
    Member
    Posted 7 years ago #

    I'm a php newb. I barely followed that. But it sounds like you don't know either?

  6. Alex Cragg
    Member
    Posted 7 years ago #

    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.

  7. vistasucks
    Member
    Posted 7 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?

  8. vistasucks
    Member
    Posted 7 years ago #

    deleted

  9. vistasucks
    Member
    Posted 7 years ago #

    or is there already?

  10. vistasucks
    Member
    Posted 7 years ago #

    Anyone?

  11. moshu
    Member
    Posted 7 years ago #

    In another topic where you posted they've found the solution...
    http://wordpress.org/support/topic/117787?replies=5

  12. vistasucks
    Member
    Posted 7 years ago #

    thx

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.