wp_get_user_contact_methods

函数
wp_get_user_contact_methods ( $user = null )
参数
  • (WP_User|null) $user Optional. WP_User object.
    Required:
    Default: null
返回值
  • (string[]) Array of contact method labels keyed by contact method.
定义位置
相关方法
_wp_get_user_contactmethodswp_update_user_countsget_user_countwp_is_large_user_countwp_get_recent_posts
引入
3.7.0
弃用
-

wp_get_user_contact_methods: 这个函数检索一个用户联系方法的数组。它返回一个包含用户联系方法的数组,这些方法用于在用户资料页面显示用户的联系信息。

设置用户的联系方法。

在3.6版本中删除了默认的联系方法。一个过滤器决定了联系方法。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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 );
}

常见问题

FAQs
查看更多 >