get_the_author_meta

Definition:
function get_the_author_meta($field = '', $user_id = false) {}

Retrieve the requested data of the author of the current post.

Parameters

  • string $field: selects the field of the users record.
  • int $user_id: Optional. User ID.

Return values

returns:The author’s field from the current author’s DB object.

Defined filters

  • get_the_author_$field
    apply_filters('get_the_author_' . $field, $value, $user_id)

Source code

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

	if ( ! $user_id )

		global $authordata;

	else

		$authordata = get_userdata( $user_id );



	// Keys used as object vars cannot have dashes.

	$field = str_replace('-', '', $field);

	$field = strtolower($field);

	$user_field = "user_$field";



	if ( 'id' == $field )

		$value = isset($authordata->ID) ? (int)$authordata->ID : 0;

	elseif ( isset($authordata->$user_field) )

		$value = $authordata->$user_field;

	else

		$value = isset($authordata->$field) ? $authordata->$field : '';



	return apply_filters('get_the_author_' . $field, $value, $user_id);

}

1803

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: