I made a menu-button on my site's first page that show "login/register". I want to change its name from "login/register" to "user account" when a user has logged in.

I tried changing codes in global.css and layout.css, but it didn't work.


I did a similar thing in many of my projects, here's how I did it:

<div class="user-panel">
        if (is_user_logged_in() ) {
            // When the user is Logged-in
            $current_user= wp_get_current_user();
            echo '<li>'. __( 'Welcome, ', 'text-domain' ) .'<strong>'. $current_user->user_nicename .'</strong></li>';
            echo '<li><a href="'. wp_logout_url( home_url() ) .'" title="Log out">'. __( 'Log out', 'text-domain' ) .'</a></li>';
            // When user is logged-out
            echo '<li><a href="'. wp_registration_url() .'" title="Register a New Account">'. __( 'Register', 'text-domain' ) .'</a></li>';
            echo '<li><a href="'. wp_login_url() .'" title="Login to the site">'. __( 'Login', 'text-domain' ) .'</a></li>';
        } ?>
<!-- /.user-panel -->

It's not a matter of CSS, it's a matter of Templating. After this, do the CSS to make it look better. :)

| improve this answer | |
  • Where should I replace this code? – SaeedS Dec 29 '14 at 23:16
  • Somewhere in your template, whether in header.php, sidebar.php - where you want to show the user menu. – Mayeenul Islam Dec 30 '14 at 4:24
  • tnx alot, how can I make a background for that, like a button theme. – SaeedS Jan 1 '15 at 17:39
  • You should better ask a new question here, if it's related to WordPress, otherwise in Stack Overflow. – Mayeenul Islam Jan 2 '15 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.