
Using WordPress Filter to Add Custom Fields in User Profile
- February 3, 2017
- Leave a comment
By default, in the WordPress user Profile section, under Contact information, there aren’t any extensive fields. However, you can add extra profile fields like links to different social media profiles and still include all the default fields (for example Email and Website) from the back-end.
This can be done simply using the WordPress filter: user_contactmethods.
You can bind your function with this filter, add the contact info fields you want in an array and simply return that array. Those fields will be added to the user profile contact info section. A sample code is given below:
1 2 3 4 5 6 7 8 9 10 11 |
function pt_additional_contact_methods( $fields ) { $fields['twitter'] = 'Twitter'; $fields['facebook'] = 'Facebook'; $fields['google-plus'] = 'Google +'; $fields[linkedin'] = 'Linkedin'; return $fields; } add_filter( 'user_contactmethods', 'pt_additional_contact_methods' ); |
User Comments