2

Possible Duplicate:
How To Add Custom Form Fields To The User Profile Page?

I'm current removing some user fields with the following code in the functions.php file:

function adjust_contact_methods( $contactmethods ) {
  unset($contactmethods['aim']);
  unset($contactmethods['jabber']);
  unset($contactmethods['yim']);
  unset($contactmethods['twitter']);
  return $contactmethods;
}
add_filter('user_contactmethods','adjust_contact_methods',10,1);

I'd like to additionally remove the website and Google+ fields, but I can't find the correct keyword. Any advice?

0

2 Answers 2

3
unset($contactmethods['googleplus']);

Is what I needed to add to my above code.

4
  • Because it wouldn't let me yet. Had to wait.
    – Mike Cole
    Aug 30, 2012 at 21:12
  • Gotcha. Forget how stringent SE is sometimes. :) Aug 30, 2012 at 21:13
  • Remind me in 4 hours. :-)
    – Mike Cole
    Aug 30, 2012 at 21:13
  • WordPress SEO plugin is adding a few additional contact methods (googleplus, twitter and facebook). In order to unset googleplus, you'd need to add the filter with a higher number in the priority parameter. For instance add_filter( 'user_contactmethods', 'magn_unset_contactmethods', 1000 );
    – julianm
    May 6, 2015 at 15:30
1

The following function is from WordPress 3.4.1 default installation source file 'user.php' starting at line 1481.

/**
 * Set up the default contact methods
 *
 * @access private
 * @since
 *
 * @param object $user User data object (optional)
 * @return array $user_contactmethods Array of contact methods and their labels.
 */
function _wp_get_user_contactmethods( $user = null ) {
    $user_contactmethods = array(
        'aim' => __('AIM'),
        'yim' => __('Yahoo IM'),
        'jabber' => __('Jabber / Google Talk')
    );
    return apply_filters( 'user_contactmethods', $user_contactmethods, $user );
}

Additional fields might have been set vi addfilter hooks.

add_filter('user_contactmethods', 'my_user_contactmethods');  

function my_user_contactmethods($user_contactmethods){  

  $user_contactmethods['twitter'] = 'Twitter Username';  
  $user_contactmethods['facebook'] = 'Facebook Username';  

  return $user_contactmethods;  
}

$user_contactmethods is an array.

Try the following code to output the array in one of your pages.

echo "<pre>";
print_r($user_contactmethods);
echo "</pre>";

You will see an array. figure out the key related to Google Plus and unset it.

unset($contactmethods['YOUR_GOOGLE_PLUS_KEY']);

Not the answer you're looking for? Browse other questions tagged or ask your own question.