Codex tools: Log in
Contents |
This function returns the desired meta data for a user. If used within The Loop, the user ID need not be specified, and the displayed data is that of the current post author. A user ID must be specified if used outside The Loop.
get_the_author_meta() returns the data for use in PHP. To display the information instead, use the_author_meta()
If the specified meta field does not exist for this user, the empty string is returned.
<?php get_the_author_meta( $field, $userID ); ?>
Get the email address for the author of the current post and store it in the $user_email variable for further use. (Remember, this function returns data, it doesn't display it.)
<?php $user_email = get_the_author_meta('user_email'); ?>
Get the email address for user ID 25, and echo it using their display name as the anchor text.
<p>Email the author: <a href="mailto:<?php echo get_the_author_meta('user_email', 25); ?>"><?php the_author_meta('display_name', 25); ?></a></p>
Plugins may add additional fields to the user profile, which in turn adds new key/value pairs to the wp_usermeta database table. This additional data can be retrieved by passing the field's key to the function as the $field parameter.
Since: 2.8.0
get_the_author_meta() is located in wp-includes/author-template.php.
the_author(), get_the_author(), the_author_link(), get_the_author_link(), the_author_meta(), get_the_author_meta(), the_author_posts(), get_the_author_posts(), the_author_posts_link(), get_author_posts_url(), get_the_modified_author(), the_modified_author(), wp_dropdown_users(), wp_list_authors()