Skip to:
Content

BuddyPress.org

Changeset 12178


Ignore:
Timestamp:
06/24/2018 06:20:34 PM (7 years ago)
Author:
boonebgorges
Message:

Add privacy policy acceptance checkbox to registration process.

When a published Privacy Policy exists on the site, a checkbox appears
just above the submit button on the registration process, which must be
checked in order to proceed with registration.

For maximum compatibility with existing sites, this change is currently
limited to Nouveau.

See #7866.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-template.php

    r11766 r12178  
    24112411
    24122412/**
     2413 * Determines whether privacy policy acceptance is required for registration.
     2414 *
     2415 * @since 4.0.0
     2416 *
     2417 * @return bool
     2418 */
     2419function bp_signup_requires_privacy_policy_acceptance() {
     2420    // Default to true when a published Privacy Policy page exists.
     2421    $privacy_policy_url = get_privacy_policy_url();
     2422    $required           = ! empty( $privacy_policy_url );
     2423
     2424    /**
     2425     * Filters whether privacy policy acceptance is required for registration.
     2426     *
     2427     * @since 4.0.0
     2428     *
     2429     * @param bool $required Whether privacy policy acceptance is required.
     2430     */
     2431    return (bool) apply_filters( 'bp_signup_requires_privacy_policy_acceptance', $required );
     2432}
     2433
     2434/**
    24132435 * Output the current signup step.
    24142436 *
  • trunk/src/bp-members/screens/register.php

    r12151 r12178  
    7373        if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] )
    7474            $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' );
     75
     76        if ( bp_signup_requires_privacy_policy_acceptance() && ! empty( $_POST['signup-privacy-policy-check'] ) && empty( $_POST['signup-privacy-policy-accept'] ) ) {
     77            $bp->signup->errors['signup_privacy_policy'] = __( 'You must indicate that you have read and agreed to the Privacy Policy.', 'buddypress' );
     78        }
    7579
    7680        $bp->signup->username = $_POST['signup_username'];
  • trunk/src/bp-templates/bp-nouveau/buddypress/members/register.php

    r12156 r12178  
    105105                </div><!-- //.layout-wrap -->
    106106
     107                <?php if ( bp_signup_requires_privacy_policy_acceptance() ) : ?>
     108                    <?php bp_nouveau_signup_privacy_policy_acceptance_section(); ?>
     109                <?php endif; ?>
     110
    107111                <?php bp_nouveau_submit_button( 'register' ); ?>
    108112
  • trunk/src/bp-templates/bp-nouveau/includes/template-tags.php

    r12156 r12178  
    24002400
    24012401/**
     2402 * Outputs the Privacy Policy acceptance area on the registration page.
     2403 *
     2404 * @since 4.0.0
     2405 */
     2406function bp_nouveau_signup_privacy_policy_acceptance_section() {
     2407    $error = null;
     2408    if ( isset( buddypress()->signup->errors['signup_privacy_policy'] ) ) {
     2409        $error = buddypress()->signup->errors['signup_privacy_policy'];
     2410    }
     2411
     2412    ?>
     2413
     2414    <div class="privacy-policy-accept">
     2415        <?php if ( $error ) : ?>
     2416            <?php nouveau_error_template( $error ); ?>
     2417        <?php endif; ?>
     2418
     2419        <label for="signup-privacy-policy-accept">
     2420            <input type="hidden" name="signup-privacy-policy-check" value="1" />
     2421
     2422            <?php /* translators: link to Privacy Policy */ ?>
     2423            <input type="checkbox" name="signup-privacy-policy-accept" id="signup-privacy-policy-accept" required /> <?php printf( esc_html__( 'I have read and agree to this site\'s %s.', 'buddypress' ), sprintf( '<a href="%s">%s</a>', esc_url( get_privacy_policy_url() ), esc_html__( 'Privacy Policy', 'buddypress' ) ) ); ?>
     2424        </label>
     2425    </div>
     2426
     2427    <?php
     2428}
     2429
     2430/**
    24022431 * Output a submit button and the nonce for the requested action.
    24032432 *
Note: See TracChangeset for help on using the changeset viewer.