the_author_meta()WP 2.8.0

Outputs the specified meta-field of the current or specified user. The meta-data is specified in the profile.

You need to specify $user_id if the function is used outside the WordPress loop.

It can be used inside the WordPress loop, in which case the $user_id parameter does not need to be specified — the data will be taken for the current post author.

1 time — 0.000012 sec (very fast) | 50000 times — 0.03 sec (speed of light) | PHP 7.1.2, WP 4.7.3
Hooks from the function

Returns

null.

Usage

<?php the_author_meta( $field, $user_id ); ?>
$field(string) (required)

Data to be output. Available fields:

user_login
user_pass
user_nicename
user_email
user_url
user_registered
user_activation_key
user_status
display_name
nickname
first_name
last_name
description or user_description
jabber
aim
yim
user_level
user_firstname
user_lastname
rich_editing
comment_shortcuts
admin_color
plugins_per_page
plugins_last_view
ID

$user_id(int)

User ID. If this parameter is specified, the function will return data for the specified user (author).

By default, data will be output for the current user (when used inside the WordPress loop).

Default: false (current user)

Examples

0

#1 Output the email of the author of the post (use the function inside the Loop):

<p>Ator's email: <?php the_author_meta('user_email'); ?></p>
0

#2 Advanced use

Some plugins can add their own meta fields for users, to display such meta fields need to specify their name in the first parameter.

Suppose the plugin added a new meta field: twitter and the value of this field is "wordpress", then the code:

<p>The author's twitter name: <?php the_author_meta('twitter'); ?></p>

Output: Twitter author name: wordpress

-1

#3 Display email of the author's with ID=45:

E-mail address of the author with ID 25: <?php the_author_meta( 'user_email', 25 ); ?>

Notes

Changelog

Since 2.8.0 Introduced.

the_author_meta() code WP 6.9.1

function the_author_meta( $field = '', $user_id = false ) {
	$author_meta = get_the_author_meta( $field, $user_id );

	/**
	 * 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
	 *
	 * @param string    $author_meta The value of the metadata.
	 * @param int|false $user_id     The user ID.
	 */
	echo apply_filters( "the_author_{$field}", $author_meta, $user_id );
}