How to Add Custom Fields to WordPress User Profile

This WordPress tutorial will walk you through the process of adding new fields to the profile page , doing this can help you gather more & more information about your users.

For Suppose you can add a field where the user needs to enter their Twitter account id or a field for Face book profile or some other custom URL.

There are Various WordPress hooks available which can be used for getting the job done simply with few lines of extra code.

If you don’t want to touch the coding part you can use the WordPress plugins like Cimy Use Extra fields, User Meta, Extra User Fields etc for Adding custom fields to your WordPress website user profiles.

How to Add Custom Fields to WordPress User Profile

Adding Extra Fields to the WordPress User Profile

Let us see an example where user needs to enter his twitter profile in the profile page.To achieve that we need to add the below lines of code to our WordPress theme’s functions.php file.

add_action( 'show_user_profile', 'add_extra_user_profile_fields' );
add_action( 'edit_user_profile', 'add_extra_user_profile_fields' );

function add_extra_user_profile_fields( $user ) { ?>
<h3><?php _e("Additional profile information", "blank"); ?></h3>

<th><label for="twitter"><?php _e("Twitter"); ?></label></th>
<input type="text" name="twitter" id="twitter" value="
<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" /><br />
<span><?php _e("Please enter your Twitter userid."); ?></span>

<?php }

add_action( 'personal_options_update', 'save_add_extra_user_profile_fields');
add_action( 'edit_user_profile_update', 'save_add_extra_user_profile_fields');

function save_add_extra_user_profile_fields( $user_id ) {

if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }

update_usermeta( $user_id, 'twitter', $_POST['twitter'] );


The above code will get the extra field information from the user & saves it to database.

Now we need to add some more code to get the custom user fields displayed on your site.

Add the below line of code to single.php file where you want the field to be displayed.

<a href="<?php the_author_meta( 'twitter' ); ?>" 
title="Follow <?php the_author_meta( 'display_name' ); ?> on Twitter">Follow 
<?php the_author_meta( 'display_name' ); ?> on Twitter</a>

Thanks to Justin Tadlock for sharing this valuable tip.Do let us know if you get into any issues while adding extra custom fields into WordPress profile page, we would be ready to help you.