• Resolved pampfelimetten

    (@pampfelimetten)


    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

Viewing 6 replies - 1 through 6 (of 6 total)
  • is_user_logged_in()

    is_user_logged_in()

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

    <?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’); ?>

    “;
    }
    ?>

    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');
    }
    ?>

    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 ?

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘howto display a different header.php when a user is logged in’ is closed to new replies.