检索当前帖子的作者的请求数据。
原型
get_the_author_meta( string $field = '', int $user_id = false )
描述
$ field参数的有效值包括:
参数
$field
(string)
(Optional)
要检索的用户字段。
$user_id
(int)
(Optional)
用户身份。
返回值
(string)
作者的字段来自当前作者的DB对象,否则为空字符串。
源文件
路径:wp-includes/author-template.php
<?php
...
function get_the_author_meta( $field = '', $user_id = false ) {
$original_user_id = $user_id;
if ( ! $user_id ) {
global $authordata;
$user_id = isset( $authordata->ID ) ? $authordata->ID : 0;
} else {
$authordata = get_userdata( $user_id );
}
if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) )
$field = 'user_' . $field;
$value = isset( $authordata->$field ) ? $authordata->$field : '';
/**
* Filters the value of the requested user metadata.
*
* The filter name is dynamic and depends on the $field parameter of the function.
*
* @since 2.8.0
* @since 4.3.0 The `$original_user_id` parameter was added.
*
* @param string $value The value of the metadata.
* @param int $user_id The user ID for the value.
* @param int|bool $original_user_id The original user ID, as passed to the function.
*/
return apply_filters( "get_the_author_{$field}", $value, $user_id, $original_user_id );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_the_author_meta/