Skip to content

Instantly share code, notes, and snippets.

@JRMorris77
Created April 4, 2018 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JRMorris77/eda87037a13e4220ae6243d208362548 to your computer and use it in GitHub Desktop.
Save JRMorris77/eda87037a13e4220ae6243d208362548 to your computer and use it in GitHub Desktop.
Add TOS/PP checkbox To BuddyPress Registration
<?php
/*
Plugin Name: Add TOS/PP checkbox To BuddyPress Registration
Plugin URI: https://premium.wpmudev.org/
Description: Inserts text links and checkbox to BuddyPress regtration form to confirm acceptance of terms and privacy policy prior to registration. Submit button is disabled if check box is not selected. To install on your site, upload to wp-content/mu-plugins/
Author: James Morris @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
add_action('bp_before_registration_submit_buttons', 'bph_show_privacy_link');
function bph_show_privacy_link() {
echo '
<script type="text/javascript">
jQuery( document ).ready(function($) {
$("#signup_submit").prop("disabled", true);
$("#tos-pp-check").on("click", function() {
if($(this).is(":checked")){
$("#signup_submit").prop("disabled",false);
} else {
$("#signup_submit").prop("disabled",true);
}
});
});
</script>
<style type="text/css" media="all">
#buddypress #signup_form.standard-form div.submit, div#terms-privacy, label#tos-pp-check {
width:50%;
padding:0 1em;
float: right !important;
}
#buddypress #signup_form.standard-form div.submit input#signup_submit {
padding:1em;
background-color:lightblue;
color:black;
}
#buddypress #signup_form.standard-form div.submit input#signup_submit:disabled, #buddypress #signup_form.standard-form div.submit input#signup_submit:disabled:hover {
padding:1em;
background-color:#ddd;
color:#999;
}
#buddypress #signup_form.standard-form div.submit input#signup_submit:hover {
padding:1em;
background-color:green;
color:white;
}
a#bp-terms-link, a#bp-privacy-link {
border-bottom:1px dotted silver;
}
</style>
<div id="terms-privacy">
Checking "I Agree" constitutes agreement to our standard <a href="http://ss.wpdevtests.com/terms/" title="Read Our Terms of Service" target="_blank" id="bp-terms-link">Terms of Service</a> and acknowledgement of our <a href="http://ss.wpdevtests.com/privacy/" title="Read Our Privacy Policy" target="_blank" id="bp-privacy-link">Privacy Policy</a>.
<br />
<label for="tos-pp-check">
<input id="tos-pp-check" type="checkbox" />
I Agree
</label>
</div>
';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment