I need a field to ensure the users who create a node accept my Terms and Conditions. I've gone as far as creating a boolean field and making it a required field but I don't know how to:

1) Disallow node creation if the checkbox isn't checked, and modify the node creation rejection message.

2) Only make the field required for non-admin roles.

3) Insert a label for the checkbox with html markup so that I can link part of the text.

1 Answer 1


There are several contrib modules available that enforce users to agree to terms or conditions. Wouldn't it be technically easier and more practical for users to agree to the terms once, when they register? The legal module is quite good for this and has a feature where if you (as the site admin) change the terms and conditions after a user has previously agreed to them, then they can be asked to re-agree to the new terms next time they login.

If you absolutely have to go down your system design path, then:

  1. You could use hook_form_alter() or hook_form__alter() to set a custom validation hook.

  2. Have a look at the conditional_fields module for making it required depending on users role. You could alternatively do this logic in the hook_form_alter() or hook_form__alter() as per #1.

  3. I'm pretty sure the Drupal Forms API won't allow links in the field label, but feel free to correct me. Alternatively you could add the links in the field description or write some jquery to achieve this (albeit a little hacky).

Hope that can help.

  • Thank you very much for the explanation. I guess I'd just include some text that goes something like "By clicking submit you agree to the terms". I've watched tutorials about the Legal module and I have a special set of terms I want to ensure that users see when they submit their creations to my site, which was why I wanted it in the node.
    – ashash
    Mar 30, 2014 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.