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
}
Related Post: Adding PHP to the Divi Theme
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.