wp_get_user_contact_methods() WordPress Function

The wp_get_user_contact_methods() function is used to retrieve the user contact methods available in a WordPress installation. This is useful for generating a list of contact methods for a user profile or settings page.

wp_get_user_contact_methods( WP_User|null $user = null ) #

Sets up the user contact methods.


Description

Default contact methods were removed in 3.6. A filter dictates contact methods.


Top ↑

Parameters

$user

(WP_User|null)(Optional) WP_User object.

Default value: null


Top ↑

Return

(string[]) Array of contact method labels keyed by contact method.


Top ↑

Source

File: wp-includes/user.php

function wp_get_user_contact_methods( $user = null ) {
	$methods = array();
	if ( get_site_option( 'initial_db_version' ) < 23588 ) {
		$methods = array(
			'aim'    => __( 'AIM' ),
			'yim'    => __( 'Yahoo IM' ),
			'jabber' => __( 'Jabber / Google Talk' ),
		);
	}

	/**
	 * Filters the user contact methods.
	 *
	 * @since 2.9.0
	 *
	 * @param string[]     $methods Array of contact method labels keyed by contact method.
	 * @param WP_User|null $user    WP_User object or null if none was provided.
	 */
	return apply_filters( 'user_contactmethods', $methods, $user );
}


Top ↑

Changelog

Changelog
VersionDescription
3.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More