Title: echo $user_name in sidebar
Last modified: August 18, 2016

---

# echo $user_name in sidebar

 *  [majost](https://wordpress.org/support/users/majost/)
 * (@majost)
 * [21 years ago](https://wordpress.org/support/topic/echo-user_name-in-sidebar/)
 * OK… So, since I’m managing a site with a lot of contributors, I thought it would
   be nice to show a greeting at the top of the theme sidebar in the form of `"Hello{
   $user_name} (Logout)"`.
 * I’m very new to word press and relatively new to PHP in general, so bear with
   me. I’ve searched through the support forums, and tried many different things,
   but nothing seems to work. The $user_* variables don’t appear to be set. I’ve
   tried using the `get_currentuserinfo()` function, as well as making the variables
   global before that, and nothing seems to work. Even the simplest `<?php get_currentuserinfo();
   echo $user_name ?>` fails.
 * Now, I’ve noticed that that the themes tend to use the functions that are within
   the template-functions-*.php files. Are they restricted access to only these 
   functions? Does that mean I need to create a new function within one of these
   files to do what I want, or is there a more graceful way?
 * Thanks in advance for any pointers anyone might be able to show me.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [majost](https://wordpress.org/support/users/majost/)
 * (@majost)
 * [21 years ago](https://wordpress.org/support/topic/echo-user_name-in-sidebar/#post-194797)
 * OK, I took my own advice and added a wp_sidebarhead() function in template-functions-
   general.php. It works. But is this kosher? I know I’d rather have the theme modified
   than one of the core wp documents.
 *  [ColdForged](https://wordpress.org/support/users/coldforged/)
 * (@coldforged)
 * [21 years ago](https://wordpress.org/support/topic/echo-user_name-in-sidebar/#post-194824)
 * majost, seems you were on the right path. Unfortunately you left out a step:
 * `<?php get_currentuserinfo(); global $user_nickname; echo $user_nickname ?>`

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘echo $user_name in sidebar’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [ColdForged](https://wordpress.org/support/users/coldforged/)
 * Last activity: [21 years ago](https://wordpress.org/support/topic/echo-user_name-in-sidebar/#post-194824)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
