July 27th, 2009 by

1. If you are logged out you will see “Please log in or Register

else if you are logged in

2. you will see “Welcome USERNAME

<?php  if (is_user_logged_in()) {
          $user = wp_get_current_user();
          echo 'Welcome <strong>'.$user->display_name.'</strong> !';
                        } else { ?>
          Please <strong><?php wp_loginout(); ?></strong>
          or <a href="<?php echo get_option('home'); ?>/wp-login.php?action=register"><strong>Register</strong></a>
          <?php } ?>

4 Responses to “Display current logged in user”

  1. Justin says:

    Thanks! works like a charm

  2. Chris says:

    Thanks a lot, works great. Had to use ” and some &nbsp-s but that’s minor :)

  3. Mauricio says:

    thanks from colombia .. you code works great.!!

  4. Stuart says:

    Been looking for this for ages thanks a million!

Leave a Reply