Add Custom Fields to User Profile in WordPress

This post will teach you that how to add custom fields to user profile in WordPress. For example you want to add some extra information like user’s facebook link , hobbies, games he plays etc. Add extra fields to a wordpress user profile is easy. Following code will show that how to add fields.

This custom function user_custom_fields_update() will update extra field of user. The WordPress hook ‘personal_options_update’ call this function while use data is saved in system.

function user_custom_fields_update(){
global $user_ID;
update_user_meta($user_ID, “user_fb”,$_POST[‘user_fb’]);
update_user_meta($user_ID, “user_youtube”,$_POST[‘user_youtube’]);
update_user_meta($user_ID, “user_linkedin”,$_POST[‘user_linkedin’]);


The custom function user_custom_fields() will shows the extra field data while we edit the user profile in site backend.

function user_custom_fields(){
global $user_ID;
$link_fb = get_user_meta( $user_ID, “user_fb”,true );
$link_youtube = get_user_meta( $user_ID, “user_youtube”,true );
$link_linkedin = get_user_meta( $user_ID, “user_linkedin”,true );
<h3>User Extra Fields</h3>
<table class=”form-table”>
<th><label>Facebook Link</label></th>
<td><input type=”text” id=”user_fb” name=”user_fb” value=”<?php echo $link_fb; ?>” /><br />
<span class=”description”>Enter your Facebook Link here.</span></td>
<th><label>Youtube Link</label></th>
<td><input type=”text” id=”user_youtube” name=”user_youtube” value=”<?php echo $link_youtube; ?>” /><br />
<span class=”description”>Enter your YouTube Link here.</span></td>
<th><label>Linkedin Link</label></th>
<td><input type=”text” id=”user_linkedin” name=”user_linkedin” value=”<?php echo $link_linkedin; ?>” /><br />
<span class=”description”>Enter your Linkedin Link here.</span></td>


add_action(‘show_user_profile’, ‘user_custom_fields’);
add_action(‘personal_options_update’, ‘user_custom_fields_update’);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s