MakeUseOf

Thursday, November 8, 2012

Wordpress – Retrieve author/user details from Post ID

Wordpress – Retrieve author/user details from Post ID: "It can be accomplished by the_author_meta() function or get_the_author_meta() function.You will need call this function in your theme or plugin, through a hook
the_author_meta() –> Outputs the data, just like echo
get_the_author_meta() -> holds the value in value.
The below function, retreives user details like…
?
CODE
1
2
3
4
5
6
7
function author_details($post_ID)  {
$auth = get_post($post_ID); // gets author from post
$authid = $auth->post_author; // gets author id for the post
$user_email = get_the_author_meta('user_email',$authid); // retrieve user email
$user_firstname = get_the_author_meta('user_firstname',$authid); // retrieve firstname
$user_nickname = get_the_author_meta('nickname,$authid); // retrieve user nickname
}
The following list of user fields you can retrieve using this function."

'via Blog this'

No comments:

Post a Comment