ID author of the best answer
I need to pull in the template file ID of the author of the best answer how to do it?
winfolk (Buyer) Answered question
![](https://secure.gravatar.com/avatar/72b0a3cbc37de22f0793bef9009006a6?s=30&d=https%3A%2F%2Fanspress.net%2Fwp-content%2Fuploads%2Fap_avatars%2F77c493ec14246d748db3ee8fce0092db.jpg&r=g)
winfolk (Buyer) commented
Yes!
$thispost_id=$post->ID; $best_answer = ap_selected_answer( $thispost_id ); $answer = get_post( $best_answer ); $author_id_best = $answer->post_author;
winfolk (Buyer) Answered question
Since 4.0, you can do this:
$best_answer = ap_selected_answer( 23 ); // Replace number with question id. $answer = get_post( $best_answer ); $author_id = $answer->post_author;
winfolk (Buyer) Posted new comment
![](https://secure.gravatar.com/avatar/72b0a3cbc37de22f0793bef9009006a6?s=30&d=https%3A%2F%2Fanspress.net%2Fwp-content%2Fuploads%2Fap_avatars%2F77c493ec14246d748db3ee8fce0092db.jpg&r=g)
winfolk (Buyer) commented
If there is no better answer then the result is 1. Why?
Rahul Aryan commented
Do a answer recount from AnsPress options -> tools.
![](https://secure.gravatar.com/avatar/72b0a3cbc37de22f0793bef9009006a6?s=30&d=https%3A%2F%2Fanspress.net%2Fwp-content%2Fuploads%2Fap_avatars%2F77c493ec14246d748db3ee8fce0092db.jpg&r=g)
winfolk (Buyer) commented
It does not help. Are there any other ways to get a user ID with the best answer?
Rahul Aryan commented
Please share your code
Rahul Aryan commented
Hello Just checked this function and never returns 1 if no answer selected. Please try updating to development version. Or contact me by email with temporary credentials.
![](https://secure.gravatar.com/avatar/72b0a3cbc37de22f0793bef9009006a6?s=30&d=https%3A%2F%2Fanspress.net%2Fwp-content%2Fuploads%2Fap_avatars%2F77c493ec14246d748db3ee8fce0092db.jpg&r=g)
winfolk (Buyer) commented
I noticed that if there is no better answer, then the ID of the author of the post is shown
Sorry I am not able to understand. You want user ID of best answer?