How to Add User Contact Fields in WordPress

Categories Components, Tutorials, Users
Add User Contact Fields in WordPress

Every user profile in WordPress has few user contact fields that can be used to display on their user or author profile. There used to be fields for some social networks, such as Yahoo IM and Jabber, in past but WordPress has removed it from its core since.

You can extend the profile contact fields by adding more fields using the user_contactmethods filter.

Adding User Contact Fields

WordPress User Contact Fields

You can add the following code to the functions.php file of your theme:

The above code will add Facebook and Twitter fields to user profile’s contact section. Later you can show these values in user’s author profile.

Retrieving User Contact Fields

You can use get_the_author_meta() function to retrieve the saved values. These values can be displayed in your user’s profile or below their posts in the author profile.

You need to pass the field and ID of the user to the function to get its value. If you use the follow function to get the value of Twitter field:

You can replace twitter in the above code with other fields, such as description or facebook, to get their values.

Leave a Reply

Your email address will not be published. Required fields are marked *