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
}

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

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.

Latest Posts

Set Custom CSS IDs for Individual Divi Accordion Items

Assigning unique CSS IDs to specific Divi Accordion items allows for precise control over styling, targeting, and linking within your page content. This ability is particularly useful when you want to apply custom designs or create anchor links to particular accordion...

Enable Swipe Navigation in the Divi Gallery Lightbox

Enabling swipe navigation in the Divi Gallery module's lightbox allows users to seamlessly browse through gallery images by swiping left or right, creating a more interactive and mobile-friendly experience. This functionality can significantly improve user engagement...

Disable Slide-In Animation for Divi Gallery Grid Images

Control how images appear in your Divi Gallery module by toggling the slide-in animation effect for grid layouts. Disabling the slide-in animation allows gallery images to load instantly and appear statically, providing a faster and distraction-free browsing...

Control Image Count Display in Divi Gallery Lightbox

Displaying or hiding the image count in the Divi Gallery module’s lightbox can help customize the user experience, depending on whether you want to give visitors an indication of gallery progress or prefer a cleaner, distraction-free view. The ability to toggle this...

Hide Gallery Image Titles in the Divi Lightbox Overlay

Displaying image titles in the lightbox overlay of the Divi Gallery module can sometimes be distracting or unnecessary, depending on your website’s design and user experience goals. Hiding these titles creates a cleaner and more focused viewing experience for visitors...

Random Posts

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