Making WordPress.org


Ignore:
Timestamp:
04/14/2021 03:56:53 AM (4 years ago)
Author:
dd32
Message:

Login: Have users agree to abide by the Privacy Policy (and later, ToS/CoC) when registering.

Enabled for all new signups.
See #5618.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/register.php

    r10898 r10899  
    66 */
    77
    8 $user_login = isset( $_POST['user_login'] ) ? trim( wp_unslash( $_POST['user_login'] ) ) : '';
    9 if ( ! $user_login && !empty( WP_WPOrg_SSO::$matched_route_params['user'] ) ) {
     8$user_login       = isset( $_POST['user_login'] ) ? trim( wp_unslash( $_POST['user_login'] ) ) : '';
     9$user_email       = isset( $_POST['user_email'] ) ? trim( wp_unslash( $_POST['user_email'] ) ) : '';
     10$user_mailinglist = isset( $_POST['user_mailinglist'] ) && 'true' == $_POST['user_mailinglist'];
     11$terms_of_service = isset( $_POST['terms_of_service'] ) ? $_POST['terms_of_service'] : false;
     12
     13if ( ! $user_login && ! empty( WP_WPOrg_SSO::$matched_route_params['user'] ) ) {
    1014    $user_login = trim( WP_WPOrg_SSO::$matched_route_params['user'] );
    1115}
    12 $user_email = isset( $_POST['user_email'] ) ? trim( wp_unslash( $_POST['user_email'] ) ) : '';
    13 $user_mailinglist = isset( $_POST['user_mailinglist'] ) && 'true' == $_POST['user_mailinglist'];
    1416
    1517$error_user_login = $error_user_email = $error_recapcha_status = false;
     
    2628    }
    2729
     30    // Don't validate that it's equal to the current revision, just that they've agreed to one.
     31    // Let the post-login interstitial handle TOS updates at time of registration.
     32    $terms_of_service_error = ! $terms_of_service || $terms_of_service > TOS_REVISION;
     33
    2834    // handle user registrations.
    29     if ( ! $error_user_login && ! $error_user_email ) {
     35    if ( ! $error_user_login && ! $error_user_email && ! $terms_of_service_error ) {
    3036        if ( ! wporg_login_check_recapcha_status( 'register' ) ) {
    3137            $error_recapcha_status = true;
    3238        } else {
    33             wporg_login_create_pending_user( $user_login, $user_email, $user_mailinglist );
     39            wporg_login_create_pending_user( $user_login, $user_email, $user_mailinglist, $terms_of_service );
    3440            die();
    3541        }
     
    7985    ?>
    8086
    81     <p class="login-mailinglist">
     87    <p class="login-tos checkbox <?php if ( $terms_of_service_error ) { echo 'message error'; } ?>">
     88        <label for="terms_of_service">
     89            <input name="terms_of_service" type="checkbox" id="terms_of_service" value="<?php echo esc_attr( TOS_REVISION ); ?>" <?php checked( $terms_of_service, TOS_REVISION ); ?> required="required">
     90            <?php
     91                $localised_domain = parse_url( wporg_login_wordpress_url(), PHP_URL_HOST );
     92                printf(
     93                    __( 'I have read and accept the %s.', 'wporg' ),
     94                    wp_sprintf_l( '%l', [
     95                        "<a href='https://{$localised_domain}/about/privacy/'>" . __( 'Privacy Policy', 'wporg' ) . '</a>',
     96                        // "<a href='https://{$localised_domain}/about/terms-of-service/'>" . __( 'Terms of Service', 'wporg' ) . '</a>',
     97                        // "<a href='https://{$localised_domain}/about/code-of-conduct/'>" . __( 'Code of Conduct', 'wporg' ) . '</a>',
     98                    ] )
     99                )
     100            ?>
     101        </label>
     102    </p>
     103
     104    <p class="login-mailinglist checkbox">
    82105        <label for="user_mailinglist">
    83106            <input name="user_mailinglist" type="checkbox" id="user_mailinglist" value="true" <?php checked( $user_mailinglist, true ); ?>>
Note: See TracChangeset for help on using the changeset viewer.