Add Terms and Conditions Checkbox to LearnDash Registration Form

Written by Dan Mossop

LearnDash comes with the "ld_registration" shortcode which can be used to add a user registration form to your site. It doesn't include the option to require the user to accept the site terms and conditions and/or privacy policy. If you'd like to add a checkbox that the user must accept in order to register, along with a custom message, here's how to do it:

Add a Terms and Conditions Checkbox in the LearnDash Registration Module

Divi Learndash Kit adds new Divi modules allowing you to easily add LearnDash components to your Divi Builder pages without the use of shortcodes. The LearnDash Registration module allows you to display a registration form in your layouts. You can easily display a "Terms and Conditions" checkbox in the form by enabling the option at:

LearnDash Registration Module Settings > Content > Show Terms and Conditions

You can set the text to be displayed by the checkbox at:

LearnDash Registration Module Settings > Content > Terms and Conditions Text

The field accepts HTML, allowing you to add links to your terms and conditions and/or privacy policy pages.

Here's the result:

 This option is available in Divi LearnDash Kit v1.5.6 upwards.

Add a Terms and Conditions checkbox via PHP

The following PHP code can be used to add a checkbox to the LearnDash registration form. 

add_action('learndash_registration_form', 'dbc_ld_registration_terms_and_conditions_field');

function dbc_ld_registration_terms_and_conditions_field() { 
	$message = 'I have read and agree to the <a href="/terms-and-conditions">Terms and Conditions</a>';
?>
<script>
jQuery(function() {
	$("#learndash_registerform #wp-submit").attr('disabled', true);
	$("#ld_registration_terms_and_conditions").click(function(){   
		$("#learndash_registerform #wp-submit").attr('disabled', !this.checked);
	});
});	
</script>
<style>
#learndash_registerform #wp-submit:disabled {
	opacity: 0.7; 
	cursor: not-allowed; 
}
</style>
<p class="learndash-registration-field learndash-registration-field-terms_and_conditions"><input type="checkbox" id="ld_registration_terms_and_conditions" style="width:auto;margin-right: 14px;"><label for="ld_registration_terms_and_conditions"><?php echo $message; ?></label> <span class="learndash-required-field">*</span></p>
<?php
}

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

We may earn a commission when you visit links on our website.

1 Comment

  1. Update 1.6.7 has just been released and improves styling when the checkbox is not checked. To better indicate that the Terms and Conditions must be accepted, it now:

    * Adds a red required star (*) after the checkbox text
    * Fades the button when it is in the disabled state
    * Changes the cursor to a "Not allowed" icon when the user hovers over the button when disabled.

    Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

New: Divi Preferred Sources Module

The Divi Preferred Sources Module adds Google’s “Add to Preferred Sources” button directly to the Divi Builder, making it easy for visitors to follow your website as a preferred source in Google Search. Add the button to posts, pages, news content, blogs and more, helping interested readers stay connected with your content through Google’s preferred sources feature.

Learn more about Divi Preferred Sources Module