Add Terms and Conditions Checkbox to LearnDash Registration Form

|

Boost Your Site and Save 20% this Weekend

Join 50,000 users and build a better site with 20% off all Divi Booster plugins.

Discount applied at checkout. Offer ends Monday!

Day(s)

:

Hour(s)

:

Minute(s)

:

Second(s)

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>
<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></p>
<?php
}

This post may contain referral links which may earn a commission for this site

Divi Booster

Hundreds of new features for Divi
in one easy-to-use plugin

0 Comments

Submit a Comment

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