I have been trying to add some custom fields to the user profile but for some reason it does not work.
I added the following code to the functions.php:
//FUNCTION for custom profile fields
function modify_contact_methods($user_contactmethods) {
// Add new fields
$user_contactmethods['user-address'] = 'Address';
$user_contactmethods['user-telephone'] = 'Telephone';
$user_contactmethods['user-avatar'] = 'Avatar';
return $user_contactmethods;
}
add_filter('user_contactmethods', 'modify_contact_methods');
It looks fine to me but I still don't see the new fields in the user profile in admin. Do I have to do anything besides this code to make it work? Or maybe my code is wrong? Any help or tips would be appreciated.
It seems correct. Have you checked by adding some priority in filter. You can do like this
add_filter('user_contactmethods', 'modify_contact_methods',99);
Use this plugin for add extra user fields in wordpress.
Plugin for add extra user fields
extra-user-fields
http://wordpress.org/plugins/extra-user-fields/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.