fbpx
How to Add Custom WordPress User Profile Fields

How to Add Custom WordPress User Profile Fields

Heres a little trick on how to add custom WordPress user profile fields.

Instructions
Add this code to your functions.php file and edit or add lines as you see fit.

function my_custom_userfields( $contactmethods ) {

    // ADD CONTACT CUSTOM FIELDS
    $contactmethods['contact_phone_office']     = 'Office Phone';
    $contactmethods['contact_phone_mobile']     = 'Mobile Phone';
    $contactmethods['contact_office_fax']       = 'Office Fax';
    
    return $contactmethods;
}
   add_filter('user_contactmethods','my_custom_userfields',10,1);

Displaying the Custom Userfields

1 Method:

<?php the_author_meta('contact_phone_office'); ?>

2 Method:

<?php the_author_meta('contact_phone_office', $current_author->ID) ?>

3 Method:

<?php $current_author = get_userdata(get_query_var('author')); ?>
<p><a href="<?php echo esc_url($current_author->contact_phone_office);?>" title="office_phone"> Office Phone</a></p>

WordPress Hosting

Leave a Reply

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

WordPress Snippet Info

Tested with Wordpress v. 4.7.1
Last Reviewed: 24.09.2017

How to Add Custom WordPress User Profile Fields
4.6 (92.5%) 8 vote[s]
Please report broken snippets.
Report Broken Snippet
WordPress Hosting - WP Engine

Recent Comments