Removing user fields

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?

Related posts

Leave a Reply

2 comments

  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']);