7 days of WordPress plugins, themes & templates - for free!* Unlimited asset downloads! Start 7-Day Free Trial
  1. Code
  2. Creative Coding

Quick Tip: Add Extra Contact Methods to User Profiles

Scroll to top
Read Time: 1 min

If you Google "add extra fields to WordPress user profile" you'll find all sorts of involved coding examples for adding extra inputs to the user profile page so you can capture additional user information. But if all you want to do is expand the default contact methods section then there's a much simpler way to go.

The user_contactmethods Filter

The user_contactmethods filter allows you to set and unset the contact info fields on the user profile page. The great thing about using this method is that WordPress looks after the creation and updating of the fields.

Let's add fields for Twitter and Facebook info. Put this in your functions.php file:

Here is what you'll get:

If you want to remove some fields, just unset them from the array:

To display the user's info, simply use the get_user_meta function.

This will show the Twitter username for the user with an ID of 1. The true argument causes the data to be returned as a single value as opposed to an array.

That's all there is to it!

Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.