Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Last active July 26, 2021 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpscholar/1224069 to your computer and use it in GitHub Desktop.
Save wpscholar/1224069 to your computer and use it in GitHub Desktop.
Add additional contact methods to a WordPress user profile
<?php
/**
* Add additional contact methods to a WordPress user profile
*/
function more_contactmethods( $contactmethods ) {
$contactmethods['twitter'] = 'Twitter username';
$contactmethods['facebook'] = 'Facebook URL';
return $contactmethods;
}
add_filter( 'user_contactmethods', 'more_contactmethods' );
Copy link

ghost commented Oct 20, 2017

How can the new contactmethod be updated/accessed? Other than the Users Pannel?

Copy link

ghost commented Apr 8, 2018

how can i add check box ???

@ayoubkhan558-zz
Copy link

ayoubkhan558-zz commented Jul 25, 2021

Why this gives warning when I check this with "Theme check" wp plugin.
REQUIRED: The theme uses the user_contactmethods filter, which is plugin-territory functionality.

@wpscholar
Copy link
Author

@ayoubkhan558 It sounds like you added it to the theme. The best practice would be to add it to a plugin. The reason is if we code it into the the theme and then a user switches themes, they lose that functionality. A theme should really just impact the look and feel of a site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment