Remove or add additional information to WordPress user profiles
Sometimes the default WordPress user contact details on user profiles are not needed, this sweet little snippet will remove or add additional information to WordPress user profiles; ideal for memberships sites.
function my_user_contactmethods($user_contactmethods){ // remove contact items unset($user_contactmethods['yim']); unset($user_contactmethods['aim']); unset($user_contactmethods['jabber']); // additional contact items $user_contactmethods['twitter'] = 'Twitter Username'; $user_contactmethods['facebook'] = 'Facebook Username'; return $user_contactmethods; }
Once saved the user information can be output using theĀ get_user_meta function, the example below is for logged in users…
if ( is_user_logged_in() ) { // gets all user data global $current_user; // gets user meta by id $user_info = get_user_meta($current_user->ID); // outputs specific user meta echo 'Twitter: ' . $user_info['twitter'][0]; echo 'Facebook: ' . $user_info['facebook'][0]; }
source: wp.tuts