Title: Shortcode Query
Last modified: August 21, 2016

---

# Shortcode Query

 *  Resolved [graemebryson5](https://wordpress.org/support/users/graemebryson5/)
 * (@graemebryson5)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/shortcode-query/)
 * Hey,
 * I’m currently using a shortcode I found to display the username of the current
   logged in user. Using the currentuserinfo section in the codex, I’ve attempted
   multiple variations to have it display the ‘firstname’ instead. I’m a total novice
   with php – is this even possible with the current code I have (below)?
 *     ```
       add_shortcode( 'current-username' , 'ss_get_current_username' );
       function ss_get_current_username(){
           $user = wp_get_current_user();
           return $user->display_name;
       }
       ```
   
 * Any advice would be massively appreciated!

Viewing 1 replies (of 1 total)

 *  Thread Starter [graemebryson5](https://wordpress.org/support/users/graemebryson5/)
 * (@graemebryson5)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/shortcode-query/#post-4636717)
 * Worked it out – here’s the code for anyone who needs it in the future! Just use
   the `current-username` shortcode to use it.
 *     ```
       add_shortcode( 'current-username' , 'ss_get_current_username' );
       function ss_get_current_username(){
           $user = wp_get_current_user();
           return $user->user_firstname;
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Shortcode Query’ is closed to new replies.

## Tags

 * [firstname](https://wordpress.org/support/topic-tag/firstname/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 1 participant
 * Last reply from: [graemebryson5](https://wordpress.org/support/users/graemebryson5/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/shortcode-query/#post-4636717)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
