Hello when I choose an answer as the best answer (I mean clicking on the Checkmark right to an answer) the question isn’t marked as resolved and I should do it manually from the status menu. How can I solve that?
1 Answers
Hi vahid,
I made a snippets here to auto reolve question when the author of question mark an answer to become the best answer:
function hook_on_metadata( $meta_id, $object_id, $meta_key, $_meta_value ) {
if( $meta_key == '_dwqa_best_answer' && is_user_logged_in() ) {
global $current_user;
$author_id = get_post_field( 'post_author', $object_id );
if( $author_id == $current_user->ID ) { // If the author of question mark the best answer
update_post_meta($object_id, '_dwqa_status', 'resolved' );
}
}
}
add_action( 'added_post_meta', 'hook_on_metadata', 10, 4 );
add_action( 'updated_post_meta', 'hook_on_metadata', 10, 4 );
Hope this help.
Regards
Hello.
thank you very mush! where should I put it?
You can add this code in the functions.php file (\wp-content\themes\your-theme).
What about hiding the answer form if the question is “resolved”? Possible?
At the moment, DW Q&A does not support this issue.
Please login or Register to submit your answer