Making WordPress.org


Ignore:
Timestamp:
05/11/2021 05:19:18 AM (4 years ago)
Author:
dd32
Message:

Registration: Remove Akismet from the flow, rely upon the heuristics instead.

File:
1 edited

Legend:

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

    r10961 r10964  
    4242
    4343    return (bool) $result['success'];
    44 }
    45 
    46 /**
    47  * Check the user registration attempt against Akismet.
    48  */
    49 function wporg_login_check_akismet( $user_login, $user_email, $user_url = '', $content = array() ) {
    50     if ( ! class_exists( 'Akismet' ) ) {
    51         return 'OK';
    52     }
    53 
    54     $payload = [
    55         'type'                 => 'user_signup',
    56         'comment_author'       => $user_login,
    57         'comment_author_email' => $user_email,
    58         'comment_author_url'   => $user_url,
    59         'comment_content'      => implode( "\n", $content ),
    60         'comment_post_ID'      => 0,
    61     ];
    62 
    63     $akismet = Akismet::rest_auto_check_comment( $payload );
    64     if ( is_wp_error( $akismet ) ) {
    65         return $akismet->get_error_code();
    66     }
    67 
    68     if ( ! empty( $akismet['akismet_pro_tip'] ) && 'discard' === $akismet['akismet_pro_tip'] ) {
    69         return 'spam';
    70     } elseif ( 'true' === $akismet['akismet_result'] ) {
    71         return 'spam';
    72     } elseif ( 'false' === $akismet['akismet_result'] ) {
    73         return 'OK';
    74     } else {
    75         return 'unknown';
    76     }
    7744}
    7845
     
    12289    }
    12390
     91    $pending_user['meta']['heuristics'] = 'allow';
    12492    if ( function_exists( 'wporg_registration_check_private_heuristics' ) ) {
    12593        // Returns block, review, allow.
     
    12795    }
    12896
    129     $pending_user['meta']['akismet_result'] = wporg_login_check_akismet( $user_login, $user_email );
    130 
    13197    $pending_user['cleared'] = (
    132         // ( !isset( $pending_user['meta']['heuristics'] ) || 'allow' === $pending_user['meta']['heuristics'] ) && // Disabled for now, review results first, replace Akismet below
    133         'spam' !== $pending_user['meta']['akismet_result'] &&
     98        'allow' === $pending_user['meta']['heuristics'] &&
    13499        (float)$pending_user['scores']['pending'] >= (float) get_option( 'recaptcha_v3_threshold', 0.2 )
    135100    );
Note: See TracChangeset for help on using the changeset viewer.