Change menu based on Logged in or out (3 posts)

  1. j.crashedata
    Posted 6 years ago #

    Here is the thing... on my WordPress blog, I added in a Log In Form to the sidebar, so users can log in right from the page they are currently on. I did not do this as a widget, as where the widget's appear on my theme are to small for a log in form. I added it into the sidebar.php file of the theme, so it appears above the two columns where widgets appear. What I want to do (and I am not quite sure how to do it) is to make it work similar to the META widget from WordPress. Basically make it so that the log in form only appears if a user is not logged in. If a user is logged in, I want it to display user links such as "Dashboard", "Profile" etc. How do I do this? Here is the full code of my sidebar.php file (the code for the existing login form in the sidebar is bold):

    [Code moderated as per the Forum Rules. Please use the pastebin]

    It may also help to know that my WordPress installation is 3.0 and is using the Theme My Login plugin by Jeff Farthing so the registration pages match my site theme, and users who log in are rerouted back to the page they logged in from instead of the backend.

    Any help would be greatly appreciated.

  2. amcmorrow
    Posted 5 years ago #

    I'm working on the same thing...if i figure anything out i'll post it here...did you ever resolve this issue?

  3. tom_taylor_85
    Posted 5 years ago #

    It is VERY simple, the code I use looks like this:

    <?php if ( is_user_logged_in() ) : ?>
    <?php include(TEMPLATEPATH."/footer.php");?>
    <?php else: ?>
    <?php include(TEMPLATEPATH."/footer2.php");?>
    <?php endif; ?>

    This code literally means: If you are logged in, display footer.php. If you aren't, display footer2.php.

    You are going to need to create an IF ELSE code to display the proper menu.

Topic Closed

This topic has been closed to new replies.

About this Topic