Saturday, July 27, 2013

How to display the login, logout and register links in Wordpress

Use this code to add user information, and to display the login/logout/register links.

<div id="user-details">
<?php
if (is_user_logged_in()) {
$user = wp_get_current_user();
echo ‘Welcome back <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 } ?>
</div>


Disqus Comments