As of version 3.8, USP Pro makes it possible to add a “disable comments” checkbox to any USP Form. This super quick tutorial shows how.

Update: USP Pro version 4.5 and beyond support both a “disable comments” field and an “enable comments” field :)

Add a Disable Comments field

To add a Disable Comments checkbox, add the following code to any USP Form:

<div class="usp-input usp-checkboxes">
	<label for="usp-comments"> 
	<input id="usp-comments" name="usp-comments" type="checkbox" value="disable"> Disable Comments</label>
</div>

You can customize most of the markup, but the input name must be usp-comments, and the value must be disable, in order to work properly. If in doubt, just copy/paste the above code as-provided into your form. No other steps or changes are required. It just works :)

To verify that the field is working, try submitting a few test posts via your form. For any submitted posts where the “disable comments” box is checked, commenting will be disabled on the submitted post. Otherwise, if the box is not checked, comments will be enabled or disabled based on your WordPress “Discussion” settings.

Pro Tip: To wrap the disable-comments checkbox with <fieldset>, you can use the [usp_fieldset] shortcode. Learn more »

Add an Enable Comments field

To add an Enable Comments checkbox, add the following code to any USP Form:

<div class="usp-input usp-checkboxes">
	<label for="usp-comments"> 
	<input id="usp-comments" name="usp-comments" type="checkbox" value="enable"> Enable Comments</label>
</div>

You can customize most of the markup, but the input name must be usp-comments, and the value must be enable, in order to work properly. If in doubt, just copy/paste the above code as-provided into your form. No other steps or changes are required. It just works :)

To verify that the field is working, try submitting a few test posts via your form. For any submitted posts where the “enable comments” box is checked, commenting will be enabled on the submitted post. Otherwise, if the box is not checked, comments will be enabled or disabled based on your WordPress “Discussion” settings.

Advanced: Make it a hidden field

The above checkbox fields enable visitors to choose whether or not to allow comments on the submitted post. But it is not necessary to give users a choice. In some cases, you may want to disable or enable comments on ALL posts submitted by some USP Form. In such case, we can change the checkbox field into a hidden field. Here is the code for disabling comments on all posts submitted through the form:

<input name="usp-comments" type="hidden" value="disable">

And here is the code for enabling comments on all posts submitted through the form:

<input name="usp-comments" type="hidden" value="enable">

The only difference between the above two hidden fields, is the value of the value attribute, which in the first case is disable, and in the second case is enable. To disable or enable comments, respectively.

When added to a USP Form, the hidden input field tells WordPress that comments should be disabled or enabled on each post. So instead of giving the user an option to disable, you are requiring comments to be disabled for posts submitted via that specific form.