Forums

[resolved] How to show user_name? (7 posts)

  1. youlichika
    Member
    Posted 1 year ago #

    I use

    <?php wp_register(); ?>
    <?php wp_loginout(); ?>

    add a login panel on the top of my page.
    but when I login in, it just show * Site Admin * Log out
    I have tied many diffrent users, they all show * Site Admin
    I noticed the login information are in wp-includes/general-template.php line 254-296, how to modify the code that can show welcome username, * Site Admin * Log out
    thanks.

  2. JohnC28
    Member
    Posted 1 year ago #

    Try this
    `
    <?php

    wp_register();

    ?>
    <?php wp_loginout(); ?>

  3. JohnC28
    Member
    Posted 1 year ago #

    Try this

    <?php
    
    if ( is_user_logged_in() ) {
    	global $current_user;
    	get_currentuserinfo();
    echo 'welcome '.$current_user->user_login;
    wp_register();
    }
    wp_loginout(); ?>
  4. youlichika
    Member
    Posted 1 year ago #

    @JohnC28 thanks, I this can echo the user name.
    By the way, how to add a li tag? Thanks.

    <ul>
    <?php wp_register(); ?>
    <?php wp_loginout(); ?>
    </ul>
  5. youlichika
    Member
    Posted 1 year ago #

    <ul>
    <li><?php wp_register(); ?></li>
    <li><?php wp_loginout(); ?></li>
    </ul>
  6. youlichika
    Member
    Posted 1 year ago #

    I modified the code like this ,but the li tag still lost...

      <?php
      if ( is_user_logged_in() ) {
      global $current_user;
      get_currentuserinfo();
      echo 'welcome '.$current_user->user_login;
      wp_register();
      }
      '
    • '.wp_loginout().'
    • '; ?>
  7. youlichika
    Member
    Posted 1 year ago #

    This still can not show li tag...

    <ul>
    <?php
    if ( is_user_logged_in() ) {
    	global $current_user;
    	get_currentuserinfo();
    echo 'welcome '.$current_user->user_login';
    wp_register();
    }
    '<li>'.wp_loginout().'</li>'; ?>
    </ul>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags