How to Create Functions to Display Information in WordPress

user functions

Many of us find that there is a need to show some user information inside a page. Today I am going to talk about a WordPress function. If you read my post carefully, you will understand how all the information of a user can be shown.

There is a function to show user information which is:


The user ID you put in place of $user_id, all the information of that user will be stored in it. You can use it anywhere. Now let’s see its usage. get_userdata($user_id) This should be put in a variable, see below:

See above I have taken a Variable called $user_data. Here you can give any name of your variable. And in the user data function I have put the number 1 user. Now that it’s done, put this function at the very top. Now if I want to show the information of that number 1 user then I have to write like this.

Now as a result of writing it, the full name of user number 1 will be seen. Due to display_name, the full name can be seen, here you follow below to show other meta information:

“user_login” User Username can be displayed.

“first_name” can show the user’s First Name.

“last_name” User’s Last Name can be displayed.

“display_name” can display the full name of the user.

“nickname” can display the Nick Name of the user.

“description” User’s description/bio can be shown.

“user_email” User’s email can be displayed.

“roles” can show the role of the user.


Let me show you how to create a full function: