I wanted to add a terms and conditions checkbox and link to the registration process. I tried the two main plugins (Agreeable and BP Xtra Signup) and found they were both buggy so figured I’d just go ahead and code it up myself. As this was to be added to the buddypress registration the hooks I was interested in were ‘bp_before_registration_submit_buttons’ and ‘bp_signup_validate’. The following can be placed in a new plugin or in your themes funcitons.php file.
[php]
/** /
* Append a terms and conditions checkbox and link to the registration form
*
* @global type $bp
*/
function innovage_add_to_registration() {
global $bp;
?>
<div class="clear"></div>
<div class="register-section" id="terms-section">
<?php do_action(‘bp_accept_tos_errors’) ?>
<label for="accept_tos">I accept the <a href=’../terms’>terms & conditions</a> (required)</label>
<input id="accept_tos" name="accept_tos" type="checkbox" value="agreed">
</div>
<?php
}
add_action(‘bp_before_registration_submit_buttons’, ‘innovage_add_to_registration’, 36);
/** /
* If the year of birth is two long – generate an error
*
* @global type $bp
*/
function innovage_validate_user_registration() {
global $bp;
if (!isset($_POST[‘accept_tos’]) || empty($_POST[‘accept_tos’]) || $_POST[‘accept_tos’] != ‘agreed’) {
$bp->signup->errors[‘accept_tos’] = __(‘Please accept the Terms and Conditions’, ‘buddypress’);
}
return;
}
add_action(‘bp_signup_validate’, ‘innovage_validate_user_registration’);
[/php]
Thanks for saving my life:)
Thanks for this 🙂 thats what I have been looking for..