Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
360 views
in Q2A Core by
Hi.

I've implemented Q2A as part of a system for a large organisation. We're nearing the end of the project, and at the last minute, their security head has added some new requirements that we must meet in order for the system to get approval to go live.

One of these requirements is that we have to force users to accept the site's Terms and Conditions every time they submit anything (ie a question, answer or comment).

This is obviously not a standard feature of Q2A (or any other system that I know of), but they are insisting on it (this is an environment where inappropriate posts could potentially endanger lives, so they have a right to be picky about these things).

I have spent some time trying to get this working. I have found myself forced into making changes to core Q2A files to get it working. And annoyingly it works quite differently in Questions compared with Answers and Comments, as the forms are posted differently, so I've had to write similar code multiple times.

I know it's an unusual requirement, but given that I've had to hack it into the core, I'm a little nervous about it getting overwritten when I have to upgrade the software. So I would like to ask for it to be considered as something that could be added to the next version of the software.

Or more plausibly, would you consider adding suitable plugin hooks that would make it possible to write a plugin for it so I wouldn't have to hack around in the core.

Thank you.

1 Answer

+3 votes
by
selected by
 
Best answer

I think this should be doable now using existing plugins.

Firstly, in the theme (or a layer plugin) you can override the form functions to add your checkbox. For example in the a_form function for answers, you can do

$a_form['fields']['tcs'] = array(
  'tags' => 'name="a_tcs"',
  'type' => 'checkbox',
  'value' => 0,
  'label' => 'Accept Terms & Conditions',
);
parent::a_form($a_form);

Second, to validate that they ticked the box, you can add a filter plugin. For the above example you'd add a filter_answer and check that $answer contains the "a_tcs" field.

Hope that helps!

 

by
Hi Scott. Thanks for the answer, that's really helpful. I had managed to get some of the way there by using the "Custom message on ask form" options in the admin panel to add HTML for the T&C checkbox to the ask form and also to the answer and comment form. However I had become stuck because the edit form doesn't have a custom HTML option, so I couldn't get it added there. I guess your solution should resolve that. I'll give it a go. Thanks again.
...