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

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

+4 votes
by
selected by
 
Best answer
  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);
}

by
+1
@sama55, nice solution thanks!

@john123, writing plugin helps you to enable disable this functionality. If you want permanent change then you can also just copy and paste function written by sama55 in qa-theme/snow/qa-theme.php file.
by
@sama55,

Layer plugin works great when hiding answers button from other users, however it also hides the answer button from admin as well.

Is there any way to allow question author and admin to view answer button on every question?

Thanks for your help.
by
+1
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);
by
@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.
+1 vote
by
Admin/
When you enter permissions you enable the padlocked  and the option to answer your own preguntas.luego to answer the question padlocked
by
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.
by
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
by
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
by
This dissolves purpose of QA platform. It is possible to do this, you need to do modifications in core or come up with plugin.
by
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.
by
Got it. quick solution can be blog plugin but whatever I tested had issues. check with arjunsuresh if he has working blog plugin.
by
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.
...