We can add custom fields to the user profile page as like the post types.
user_contactmethods filter will do the trick
if (!function_exists('custom_user_contactmethods')) {
function custom_user_contactmethods($user_contactmethods) {
return array_merge($user_contactmethods, array(
'address1' => __('Address Line1')
/*We can add multiple fields in this array.*/
)
);
}
}
add_filter('user_contactmethods', 'custom_user_contactmethods', 5, 1);
Note: The fields added through this filter will get appeared only while editing the user's profile page. It wont be available while creating a user.
No comments:
Post a Comment