/**
* Register new user contact details.
*
* @param array $fields User contact fields.
*
* @return array
*/
function dorzki_register_new_contact_details( $fields ) {
$fields['github'] = __( 'GitHub', 'dorzki' );
return $fields;
}
add_filter( 'user_contactmethods', 'dorzki_register_new_contact_details' );
How to use it?
Usually adding functionality to a WordPress site is by creating a plugin.
However you can simply copy the code and paste it in your child theme’s functions.php
file at the end of the file, just before ?>
.
For JavaScript code you will need to add them to your theme’s main JavaScript file.
Having issues with the code?
If the code doesn’t work or you get an error please let us know in the comments section.
We will do our best to fix it as-soon-as-possible and update the code on this page.
Comments
How can I display those fields?
Hi Alon,
In order to display one of the contact fields, use the following code:
Replace the `$user` with the current user object or with the current author page ID.
Please do well to explain what exactly the code does, If possible, add screenshots of the outcome. You doing a great job tho.
Hi Kilson,
Will try to do so from now on 🙂