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
winfolk (Buyer) commented
Yes!
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
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.
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.
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?