Comment-Policy WordPress Plugin

This plugin adds an extra required field in the comment form. This is actually a checkbox with a link to your comment policy page. The visitor must accept the provided comment policy in order to submit a comment. This plugin affects the comment submission and not trackbacks/pingbacks.

This plugin adds an extra required field in the comment form. This is actually a checkbox with a link to your comment policy page. The visitor must accept the provided comment policy in order to submit a comment. This plugin affects the comment submission and not trackbacks/pingbacks.


Prior to installing this plugin, you need to take care of three simple configuration options. Open the comment-policy.php file in a text editor and fill the proper URL and page title of a web page that contains your site’s policy about comments and interaction in general.

$policy_page_URI = '';
$policy_page_title = 'Privacy Statement and Terms of Use';

Also, set a custom name for the new field this plugin adds to the comment-form. You can type anything you like as long as you use only letters. Read the next section for more info on this.

$cp_form_field_name = 'anynamewithletters';

How it works

This plugin adds an extra required field to your comment form, a checkbox, which the reader needs to check in order to successfully submit a comment. In other words, the reader needs to accept your comment policy before submitting the comment.

By default, that checkbox is given an initial name, (comterms). When the page is loaded on a browser, the checkbox’s name is modified with Javascript and is set to the name you have specified in the $cp_form_field_name variable, which is actually the field that is checked by WordPress. This means that only browsers or bots that support Javascript can succesfully submit comments to your blog. Without Javascript support, no comment can be actually submitted, even if the checkbox is checked.

Of course you can always override this behaviour by setting the $cp_form_field_name variable to comterms. This way, any client, regardless of the fact that it supports Javascript or not, can successfully submit a comment.

Note that pingbacks/trackbacks are in no way affected.

Will This Stop Spam?

Yes and No. Actually, this will only stop comment spam produced by bots, that can parse your comment form but do not support Javascript – my stats show that this is the majority of the spambots -, or by poorly made spambots, which target the wp-comments-post.php file directly. Also, as it was mentioned above, trackbacks are not affected.

This plugin intends to be an extra measure in the fight against comment spam. I highly recommend using this plugin in combination to another spam killer, like Akismet.


Having set the options that where described in the “Configuration” section, place the comment-policy.php file in your /wp-content/plugins/ directory and activate through the administration panel.


WordPress’ default stylesheet sets the width of all the input fields of the comment form to 170 pixels. This results in a … w-i-d-e checkbox. If you don’t like this (which is very likely), you could simply comment out the width property in your stylesheet:

#commentform input {
    /* width: 170px; */
    padding: 2px;
    margin: 5px 5px 1px 0;

Or, better, define a separate class for the form elements, for which you want to set the width property. But this will not be covered here… If anybody feels like writing a step-by-step guide for novice users, I’d be glad to link to such a tutorial.


For WP versions prior to 2.00, you are on your own…


This project is released under the terms of the GNU General Public License.

Downloads, Issue Tracking, Support

For the latest releases of Comment-Policy please visit the downloads section of the Comment-Policy Development Portal.

The development website also hosts an issue tracking facility, where you can submit your feature requests or report bugs, and discussion boards, where you can get first class support from the community of users.


This plugin is released as free software. Nevertheless, its development requires time and effort. A small donation, as a sign of appreciation of the effort, is welcome. Please, use the following button to visit the Donations page. Thanks in advance for your support!

Donations Button

Comment-Policy WordPress Plugin by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Permissions beyond the scope of this license may be available at Licensing Information.
Copyright © 2006 - Some Rights Reserved

About George Notaras

George Notaras is the editor of G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is a GNU/Linux enthusiast, a self-taught programmer and system administrator. He strongly believes that "knowledge is power" and has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora and spends some of his spare time developing open-source software. Follow George on Twitter: @gnotaras

17 responses on “Comment-Policy WordPress Plugin

  1. scart Permalink →

    does it work in ajax comment? or any ajax plugin installed in the blog?

  2. KeepReadingUs Permalink →


    I am using wpv2.0.5 and activated this plugin based on the instructions on this page. But the checkbox option doesn’t show up for me.

    I also have the ajax comments installed. is that causing any problem for this to work fine?


  3. George Notaras Post authorPermalink →

    Unfortunately, I don’t have the time to check what the problem might be. The comment policy plugin is supposed to work with the default comment form of WordPress. Sorry.

  4. KeepReadingUs Permalink →

    Thank you Gnot. i wish i could get this to work. :)

    Pls do check whenever you get some spare time or when you update this plugin next time.

    Thank you.

  5. Tom Permalink →

    i wait it long!

  6. RandomLogic Permalink →

    Great plugin, just what my simple mind needs.

    It’s working great with ajax comments too!

    I have a suggestion though: The “secret” key used to rename the formfield could also be done in a more sophisticated why by calculating a fieldname based on a secret and algorith only known to the server (e.g. XOR or something like that) which is reversed when the post is made to calculate the correct name to be retrieved.

    Does that sound sane to you?


  7. George Notaras Post authorPermalink →

    Thanks for testing it with AJAX comments. :-) Indeed, there are more sophisticated ways to implement this concept.

    IIRC, I had tried to use a secret field name that was modified dynamically every time the page was loaded, but this method had a drawback in the case a human user had forgot to accept the terms and had to go back and check the checkbox. Actually, I cannot remember what exactly was wrong (I have to try it again :-) ), but I would have to make the code more complex in order to overcome that issue, which is something I generally do not like. I like the plugin code to be as simple as possible for easy maintenance. But, I’ll recheck this when I have some free time.

    Although the current implementation is very simple, it works fine for the moment. Almost all comment spam attempts from bots (and these are some thousands/month) end up with a 403 (forbidden) error code and never even reach akismet, which eventually has to deal with trackback/pingback spam only.

  8. Melle Permalink →

    Thanks, I needed this!

  9. Eduardo Larequi Permalink →

    Thank you for this excellent plugin.

    I’ve trying to style Comment-Policy in order to have it just before the Submit Comment button (“enviar comentario” in spanish), but to no avail.

    I’m using the Tarski theme. Any idea?

    Thanks in advance.

  10. George Notaras Post authorPermalink →

    Hi Eduardo,

    The plugin should take care of this, provided that the comment textarea id is “comment”. Your textarea has this id, so I am out of ideas of what might be wrong. I’ll try to use the theme you use on a test blog and also would like to know the name of the “comment preview” plugin you use in your blog. Maybe there is a conflict with that plugin which needs to be resolved.

    Thanks for your feedback.

  11. Eduardo Larequi Permalink →

    Thanks, GNot, for your quick answer.

    I’m using Live Comment Preview plugin. I’ve deactivated it for a while in order to check the position of Comment-Policy checkbox, but even without Comment Preview this checkbox appears under Submit Comment button.

    After this test, I’ve reactivated the Live Comment Preview plugin.

  12. George Notaras Post authorPermalink →

    I had some time to take a look at it. Finally, it has nothing to do with the preview pluging.

    The automatic (using javascript) placement of the comment-policy checkbox does not work with the Tarski theme’s comment form. I tried for a while to find a quick workaround, but I didn’t manage to do it. I’ll try to find another more general way to arrange elements in a future version.

    Until then, if you find a workaround, I would be very glad to know about.

  13. Eduardo Larequi Permalink →

    I’ll try to contact Tarski theme creators. If they can find an easy solution, I’ll inform you.

    Anyway, thank you very much for your interest.