This tutorial will show you the way to add custom fields for user profile in dashboard. This is very simple, ease of use & light code to follow.
So, now move to the point. Just open your functions.php
file & paste the below code:
// CUSTOM USER PROFILE FIELDS function user_custom_additionalfields( $contactmethods ) { // ADD CONTACT CUSTOM FIELDS $contactmethods['contact_phone_office'] = 'Office Phone'; $contactmethods['contact_phone_mobile'] = 'Mobile Phone'; $contactmethods['contact_office_fax'] = 'Office Fax'; // ADD ADDRESS CUSTOM FIELDS $contactmethods['address_line_1'] = 'Address Line 1'; $contactmethods['address_line_2'] = 'Address Line 2 (optional)'; $contactmethods['address_city'] = 'City'; $contactmethods['address_state'] = 'State'; $contactmethods['address_zipcode'] = 'Zipcode'; return $contactmethods; } add_filter('user_contactmethods','user_custom_additionalfields',10,1);
NOTE: You can change your desired input name & value.
Once you paste the above code you will able to see below fields in user profile:
There are two options to view this value in front. You can choose anyone from below:
OPTION-1:
<?php the_author_meta('contact_phone_mobile', $current_author->ID);?>
OPTION-2:
<?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>
Hope this shortest function helped you to add your own custom user fields in WordPress. Still if you face any trouble, feel free to contact me by dropping a message.
Thanks.
This post has already been read 4796 times!
What is Lead Capture: In general sense lead capture designates a process or way of…
Introduction Unlimited Modal POPUPS on MouseClick: Everyone knows about popup during site visits and most…
Brief about Pregnancy Calculator : This WordPress Pregnancy Calculator plugin allows users to display an…
Introduction About this Service Plugin: This Visual Composer Service Plugin works as an addon to…
Introduction of Dynamic Query String : This plugin allows user to set dynamic query string…
There is an occasional bug for iPhone and iPad even they are designed as well and…