• Resolved graemebryson5

    (@graemebryson5)


    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

    (@graemebryson5)

    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.