apply_filters( ‘user_contactmethods’, string[] $methods, WP_User|null $user )

Filters the user contact methods.

Parameters

$methodsstring[]
Array of contact method labels keyed by contact method.
$userWP_User|null
WP_User object or null if none was provided.

More Information

Customize the contact information fields available to your WordPress users. Edits the available contact methods on a user’s profile page. Contact methods can be both added and removed.

Source

return apply_filters( 'user_contactmethods', $methods, $user );

Changelog

VersionDescription
2.9.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    Example migrated from Codex:

    Add & remove user contact methods.

    add_filter( 'user_contactmethods', 'modify_user_contact_methods' );
    
    function modify_user_contact_methods( $methods ) {
    
    	// Add user contact methods
    	$methods['skype']   = __( 'Skype Username'   );
    	$methods['twitter'] = __( 'Twitter Username' );
    
    	// Remove user contact methods
    	unset( $methods['aim']    );
    	unset( $methods['jabber'] );
    
    	return $methods;
    }
  2. Skip to note 4 content

    Add user contact methods useing OOP.

    class WPDocs_AuthorBio {
    
        /**
         * Constructor.
         */
        public function __construct() {
            add_filter( 'user_contactmethods', array( $this, 'user_contact_methods_render' ) );
        }
    
        /**
         * User Contact information
         *
         * @param array $methods
         *
         * @return array
         */
        public function user_contact_methods_render( $methods ) : array {
    
            $methods['facebook'] = __( 'Facebook' );
            $methods['twitter']  = __( 'Twitter' );
            $methods['linkedin'] = __( 'Linkdin' );
            $methods['skype']    = __( 'Skype' );
    
            return $methods;
        }
    }
    
    new WPDocs_AuthorBio();

You must log in before being able to contribute a note or feedback.