asked 8 years ago

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
answered 8 years ago

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.

vahid moh
replied 8 years ago

thank you very mush! where should I put it?

Dominic Staff
replied 8 years ago

You can add this code in the functions.php file (\wp-content\themes\your-theme).

Yan Susanto
replied 7 years ago

What about hiding the answer form if the question is “resolved”? Possible?

Dominic Staff
replied 7 years ago

At the moment, DW Q&A does not support this issue.

Powered by DW Question & Answer Pro