Created
June 6, 2012 16:35
-
-
Save habibmac/2883112 to your computer and use it in GitHub Desktop.
WP: Custom user profile fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CUSTOM USER PROFILE FIELDS | |
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'; | |
// 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','my_custom_userfields',10,1); | |
// To display custom fields you can use one of the two methods listed below. | |
// Option 1: | |
the_author_meta('facebook', $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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment