Forums

[resolved] howto display a different header.php when a user is logged in (7 posts)

  1. pampfelimetten
    Member
    Posted 5 years ago #

    hello folks,

    does anybody has suggestions how to change the header, when a user is logged in?

    in my example, i want to have a link in an image (which is a lock) in the header.php. when the user is logged in, i would
    like to exchange the picture with another menu.

    maybe does there exist a Conditional Tag like is_loggedin?
    or something similar?

    thanks for your help in advance
    best wishes,
    thomas

  2. whooami
    Member
    Posted 5 years ago #

    is_user_logged_in()

  3. gspark
    Member
    Posted 4 years ago #

    is_user_logged_in()

    is not very specfic how about an example on how to use it :)

  4. gspark
    Member
    Posted 4 years ago #

    <?php
    get_currentuserinfo();
    if (empty($user_ID)) {
    echo "yes";
    } else {
    echo "no";
    }
    ?>

    this one sort of works but i can't figure out how to include php inside it like this example

    get_currentuserinfo();
    if (empty($user_ID)) {
    echo "
    <?php wp_list_pages('include=1,2,3&title_li=&depth=1'); ?>
    ";

    } else {
    echo "

    <?php wp_list_pages('include=3,4,5&title_li=&depth=1'); ?>

    ";
    }
    ?>

  5. Adam Brown
    Member
    Posted 4 years ago #

    If you're in the middle of some PHP, you don't need the <?php. Sticking with your method, try this:

    <?php
    get_currentuserinfo();
    if (empty($user_ID)) {
      wp_list_pages('include=1,2,3&title_li=&depth=1');
    } else {
      wp_list_pages('include=4,5,6&title_li=&depth=1');
    }
    ?>
  6. gspark
    Member
    Posted 4 years ago #

    that did the trick thanks :) I'm thinking if we want to use
    < ul >
    < li > on individual menu items (example - home) we have to use echo ' '; correct ?

  7. Adam Brown
    Member
    Posted 4 years ago #

    Echo is for printing something specific to the browser (as if it were in a plain vanilla html file). So yes. But the wp_list_pages function has an echo built-in, which is why the way you originally wrote it wouldn't have worked.

Topic Closed

This topic has been closed to new replies.

About this Topic