How to add custom field to user profile for a wordpress blog

0 Flares 0 Flares ×

The profile fields provided by wordpress may not be sufficient, some time you may need to have some more fields to describe a user or author profile in details, for example if you would like to add a LinkedIn profile URL to the user profile or a Facebook URL to the user profile, but current version of wordpress does not have this feature. There might be plugin to do so but use of too many plugins may result in poor performance of your blog. So in this article I will describe how you can add a custom field to user profile by adding some lines of code.


How to add a custom field to user profile for a wordpress blog?


wordpress custom profile field


For adding a custom field to use profile you need to add some codes to your template files, basically you just need to add the code to “functions.php” file of your template. So lets see it with an example. Lets assume that you want to add a custom field which will contain the LinkedIn URL of the user.


STEP1: Open the functions.php file of your theme with your favorite editor (You can find it inside wp-content/themes/Your-theme folder). Add the below lines of code to functions.php file at the bottom just before “?>”.

function jafaloo_add_linkedin_profile( $contactmethods ) {
// Add LinkedIn Profile
$contactmethods[‘linkedin_profile’] = ‘LinkedIn Profile URL’;
return $contactmethods;

add_filter( ‘user_contactmethods’, ‘jafaloo_add_linkedin_profile’, 10, 1);

Description of the code: Here we are creating a new function “jafaloo_add_linkedin_profile” where we are adding a new field to the user_contactmethods and add_filter will register the field to wordpress.


After saving the file login to your account and click on the user profile link, you can see a new contact field has been added as shown above in the image.


How to display or access custom field value?


As above we have added a custom field for the LinkedIn profile URL, now its time to show the field value. You can access the value using the below code

$linkedin_profile = get_the_author_meta(‘linkedin_profile’,USER-ID);

Just replace the USER-ID with the username of the user and $linkedin_profile will contain the LinkedIn profile URL of the user.


If you have any problems or question in implementation please do let me know with your comments.


+Ayodhyanath Guru holds a B.Tech degree in Electrical Engineering and has worked with various prestigious clients in the IT industry and presently working as a Software Engineer. He is a part time blogger and presently authors the Jafaloo.Com blog. Being a tech enthusiast Guru likes to surf the web and blogs about interesting technical topics like How-To guides, freewares, Tutorials, Software, Gadgets, web applications etc. Apart from blogging he likes coding in Java/J2EE and PHP.

You may also like...

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 0 Flares ×