Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
2.1k views
in Q2A Core by
edited by

What is the best way to disable the option: remove selected answer?

I.e. php wise, jquery I can find out :)

Would be great if only the admin could remove it.

4 Answers

+4 votes
by
selected by
 
Best answer

answering myself:

in qa-theme-base.php comment out: 

elseif (isset($post['unselect_tags']))
                $this->post_hover_button($post, 'unselect_tags', '', 'qa-a-unselect');

This does not set the <input> and the user cannot unselect the best answer...

---

Thing that is missing: check if ADMIN to allow him the unselect...

5 min later... got it :)

            elseif ( isset($post['unselect_tags']) && (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) )
                $this->post_hover_button($post, 'unselect_tags', '', 'qa-a-unselect');

have a great week-end!
Kai
 

by
Update: Strange, from my eventlogger I see that some users are still able to unselect the best answer. I have no idea why!
by
Not strange, I realized that users can still vote for another answer as best answer, which unselects the previous chosen best answer!
+2 votes
by

I found the solution for this...

In addition to your code what you need to do is disable other buttons using jQuery...but not in a_selection() function but in a_list () funciton

in a_list() function add below code and done..

 

if($a_list['as'][0]['selected'] == true)
$this->output('<script>$(".qa-a-select-button").attr("disabled", true);</script>');
 
Make sure it is required page refresh to take full effect....
 
I don't know if it is right way or not.. but it works
by
I tried this on the Version 1.74. but I doesn't work. Where do you exactly write the code? Can you show me more detailed instruction please?

I put the above code below the function

public function a_list($a_list)

but it doesn't seem to affect anything even if I do the page refresh.
0 votes
by
This is gonna help me alot. In addition, i want to negatif points members not to be select best answer.

What function should i add?
by
I think i found
qa_get_logged_in_points()
by
I tried, it works.
–1 vote
by

This plugin works fine on version 1.8 https://github.com/yshiga/q2a-best-answer-restriction smiley

...