ID author of the best answer

6.53K viewsGeneral
0

I need to pull in the template file ID of the author of the best answer how to do it?

Answered question

Sorry I am not able to understand. You want user ID of best answer?

0

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;

Posted new comment

If there is no better answer then the result is 1. Why?

Do a answer recount from AnsPress options -> tools.

It does not help. Are there any other ways to get a user ID with the best answer?

Please share your code

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.

I noticed that if there is no better answer, then the ID of the author of the post is shown

You are viewing 1 out of 2 answers, click here to view all answers.