Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

How to allow only author to answer his own question? Thanks for your help.

+3 votes
170 views
asked May 8 in Q2A Core by john123

Is it possible that only author of the question allowed to answer his own question? All other users can comment on the answers but can not post answers.

1. Author can create question
2. Author can answer his own question
3. Other users can not answer but only can comment on answers.

I tried with permissions, but it enables answers for all users OR disables answers for all users.

Thanks for your help.

Q2A version: Latest

3 Answers

+1 vote
answered May 9 by MONKEY
Admin/
When you enter permissions you enable the padlocked  and the option to answer your own preguntas.luego to answer the question padlocked
commented May 9 by john123
Hi Monkey !  I understand what you mean.
Author closes the question, no one can answer it and can make comments on answer.

Which is great. However if author opens the question to add additional answers, it opens for everyone to add answers as well.
commented May 9 by MONKEY
Well those who respond clarifies that for now is only your update that please do not do if they do is simple because you can hide them
commented May 9 by john123
Thanks for your reply.

Other option would be to hide answer button for other users. Only author of the question can view answer button.  Other users can only view comment button.
+1 vote
answered May 9 by ProThoughts
This dissolves purpose of QA platform. It is possible to do this, you need to do modifications in core or come up with plugin.
commented May 9 by john123
Hi ProThoughts ! Thanks for your reply. Purpose of this is to allow experts to raise question and answer their own question to educate others. Others can make comments on expert provided answer but can not answer the question. Its like community of teachers.
commented May 9 by ProThoughts
Got it. quick solution can be blog plugin but whatever I tested had issues. check with arjunsuresh if he has working blog plugin.
commented May 9 by john123
ProThoughts !

Blog plugin does not have extended functionality of q2a.  It only allows comments not answers. It would be like blog post but not question - answer type of discussions.

I want only author (teacher)  to be able to add answers, not other users. is it possible to override answer button visibility?

What i  mean is only author of the question can view answer button, other users can not see answer button at all, but only comment button.
+3 votes
answered May 9 by sama55
edited May 11 by sama55
  1. Create your layer plugin.
  2. Replace "c_list" function inner layer plugin with "q_view_buttons" function below.

public function q_view_buttons($q_view) {
    if(qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR​) {
        if(isset($q_view['form']['buttons']['answer'])) {
            if(qa_is_logged_in() && $q_view['raw']['handle'] != qa_get_logged_in_handle()
            ||(!qa_is_logged_in() && $q_view['who']['data'] != qa_lang_html('main/me'))) {
                unset($q_view['form']['buttons']['answer']);
            }
        }
    }
    qa_html_theme_base::q_view_buttons($q_view);
}

commented May 11 by sama55
I changed code above. You can change user level (QA_USER_LEVEL_MODERATOR) along list below.
define('QA_USER_LEVEL_APPROVED', 10);
define('QA_USER_LEVEL_EXPERT', 20);
define('QA_USER_LEVEL_EDITOR', 50);
define('QA_USER_LEVEL_MODERATOR', 80); // <== Now level
define('QA_USER_LEVEL_ADMIN', 100);
define('QA_USER_LEVEL_SUPER', 120);
commented May 12 by john123
@sama55,

Thank you for updated code. It works great. Now admin can view answer button on all questions and other registered users can see answer button on their own question only.

Great insights. Thank you so much for taking the time to update the code.
...