Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+15 votes
in Plugins by
edited by

Download and Instructions:


Question2Answer Plugin: Flag Reasons


Adds choice of flag reasons and comment option to each flag vote


  • user gets list of reasons to choose from when clicking on the button "flag"
  • user can add a comment
  • flags and reasons are listed at post


  • Download the plugin as ZIP from github
  • Make a full backup of your q2a database before installing the plugin.
  • Extract the folder q2apro-flag-reasons from the ZIP file.
  • Move the folder q2apro-flag-reasons to the qa-plugin folder of your Q2A installation.
  • Use your FTP-Client to upload the folder q2apro-flag-reasons into the qa-plugin folder of your server.
  • Navigate to your site, go to Admin -> Plugins and check if the plugin "q2apro Flag Reasons" is listed.
  • Initialize the database (this will create a table qa_flagreasons)
  • Congratulations, your new plugin has been activated.


The code is probably okay for production environments, but may not work exactly as expected. You bear the risk. Refunds will not be given!

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


All code herein is OpenSource. Feel free to build upon it and share with the world.

Final Note

If you use the plugin:

  • Translate the plugin into your language and commit the language file.
  • Say thank you by donating a few to the developer.

Have fun!

Update v0.2:

- Flagging of answers and comments now possible.
- Key listener for Enter (submit) and Escape (cancel).
- Click on semi-transparent background closes overaly.

Q2A version: 1.8.0
Before updating to the new version, please delete the former table qa_flagreasons, and re-initialize. Because I renamed the "comment" field to "notice" to be more clear.
Is there any way to hide who flagged from the reasons list. Showing who flagged will rise some hatred among members. So how to make it as only reasons be posted.
Thank you, it is working now. It wasn't working at first as the code was not encoded in UTF 8. It was in Windows 1252. So the lines after 146 or so were not visible. But however, it was visible on a free hosting where I do some experiments. But still, no changes occurred there :)
Today I tried it by copying the whole code from GitHub and saving it as UTF 8 file. And it worked. Thank you for the help.

6 Answers

0 votes
so cool plugin, I'll use it on my site. Thanks !
+1 vote
Wow! this plugin too essential for every site. Thank you very much.
True, I created it because many of my users asked for it. They could not understand many spam flags, which were essentially not spam but "notices" for moderators to take care of something.
0 votes
Very useful plugin for a very active website. How can we hide the username of the user who flagged? Flag reasons or notice is enough. Username display should be an option. What change in code can make that not to display  username after reasons or notices?
+1 vote
You should improve this plugin. It lacks security hacks. The spam text input area accepts php and html codes. BE AWARE.
In my opinion, your comment is not true. The notice text and other incoming data is saved with q2apro_save_flagreasons() that uses qa_db_query_sub(), with placeholders # $ that get sanitized by the q2a core. See qa-db.php. Please elaborate where you see a security issue.
try this. flag one post and write this on spam text area;
<a href="https://twitter.com">click it</a><div style="font-size:145px;">HACKED</div>

and see the results.

To fix it you should sanitize following code at layer.php
public function post_meta_flags($post, $class)
            if($class=='qa-a-item' || $class=='qa-c-item')
                $flaginfo = q2apro_count_postflags_output($post['raw']['postid']);
                    // add flag info to flag output
                    $post['flags']['suffix'] .= ': <br>'.$flaginfo;
        // default method call outputs the form buttons
        qa_html_theme_base::post_meta_flags($post, $class);
Thanks! Fixed by: $post['flags']['suffix'] .= ': <br>'.htmlspecialchars($flaginfo);
+1 vote
A great plugin....thank you so much.

Greet job
0 votes
Very good plugin, I like it. Thanks to q2apro.