Making WordPress.org

Changeset 11505


Ignore:
Timestamp:
02/02/2022 08:40:57 AM (3 years ago)
Author:
dd32
Message:

Login: Run the wp_insert_user() filters during the registration process.

This prevent filters/errors that occur during the pending->user account process not being surfaced during registration.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login
Files:
3 edited

Legend:

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

    r11485 r11505  
    337337            $value = trim( sanitize_text_field( wp_unslash( $_POST['user_fields'][ $field ] ) ) );
    338338            if ( 'url' == $field ) {
     339                /** This filter is documented in wp-includes/user.php */
     340                $value = apply_filters( 'pre_user_url', $value );
     341
    339342                if ( $pending_user ) {
    340343                    $pending_user['meta'][ $field ] = esc_url_raw( $value );
     
    367370        $new_email !== $pending_user['user_email']
    368371    ) {
     372        /** This filter is documented in wp-includes/user.php */
     373        $new_email = apply_filters( 'pre_user_email', $new_email );
     374
    369375        // Validate the email
    370376        $error_user_email = rest_do_request( new WP_REST_Request( 'GET', '/wporg/v1/email-in-use/' . urlencode( $new_email ) ) );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-restapi.php

    r11081 r11505  
    7575    $email = trim( urldecode( $request['email'] ) );
    7676
     77    if ( ! is_email( $email ) ) {
     78        return [
     79            'available' => false,
     80            'error' => __( 'That email address appears to be invalid.', 'wporg' ),
     81        ];
     82    }
     83
    7784    if ( $user = get_user_by( 'email', $email ) ) {
    7885        return [
     
    8895
    8996    // And that there's no pending account signups for other emails for that inbox.
    90     if ( ! $pending && false !== strpos( $email, '+' ) ) {
     97    if ( ! $pending && str_contains( $email, '+' ) ) {
    9198        $pending = wporg_get_pending_user_by_email_wildcard( $email );
    9299    }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/register.php

    r11073 r11505  
    2323$error_user_login = $error_user_email = $error_recapcha_status = $terms_of_service_error = false;
    2424if ( $_POST ) {
     25
     26    /** This filter is documented in wp-includes/user.php */
     27    $user_login = apply_filters( 'pre_user_login', $user_login );
     28
     29    /** This filter is documented in wp-includes/user.php */
     30    $user_email = apply_filters( 'pre_user_email', $user_email );
    2531
    2632    $error_user_login = rest_do_request( new WP_REST_Request( 'GET', '/wporg/v1/username-available/' . urlencode( $user_login ) ) );
Note: See TracChangeset for help on using the changeset viewer.