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 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.
1 Answer
Reset to default 0I did a similar thing in many of my projects, here's how I did it:
<div class="user-panel">
<ul>
<?php
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>';
}
else
{
// 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>';
} ?>
</ul>
</div>
<!-- /.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. :)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745081520a4610154.html
评论列表(0条)