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
}

Seamlessly Integrate LearnDash with Divi!

Elevate your LearnDash LMS with the Divi LearnDash Kit from Divi Booster. This plugin adds custom LearnDash modules to Divi, resolves compatibility issues, and supports Divi design settings, creating a cohesive and visually appealing learning environment. Perfect for adding features like the "Terms and Conditions" checkbox to your registration forms easily.

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, 

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 *.

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

Latest Posts

Hide the Page Title in the Hello Elementor Theme

Hiding the page title in the Hello Elementor theme allows you to create a cleaner and more customized page layout, free from default headings that may not fit your design. This is particularly useful for landing pages or custom content layouts where the default page...

How to Hide a Divi Module When Scrolling Up or Down

In this quick tutorial, I’ll show you how to hide a Divi module when scrolling in a specific direction (up or down), so that the module only shows when you want it to. This is especially useful when using Divi’s Scroll Effects feature and you have a effect you want to...

Fade a Divi Image Module Edge into the Background

Want to create a stylish fade effect on your Divi image module—where one side fades smoothly into the background? With a bit of CSS, you can make any edge (or corner) of the image fade out: top, bottom, left, right, or even diagonally.Fade a Divi Image Module Edge...

Hide the Header and Footer in the Hello Elementor Theme

Removing the default header and footer from your Hello Elementor theme allows for a streamlined and distraction-free website design. This is especially useful when creating unique landing pages, full-width layouts, or custom headers and footers with a page builder. In...

Setting up the Divi Password Box Module

Setting up password protection on a page can help you control access to sensitive or private content in WordPress, allowing only authorized visitors to view certain sections. With the Divi Password Box module, you can replace the plain Divi password form with a fully...

Random Posts