Making WordPress.org

Changeset 10890


Ignore:
Timestamp:
04/13/2021 07:48:42 AM (6 years ago)
Author:
dd32
Message:

Login: Record Akismet data on signups.

File:
1 edited

Legend:

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

    r10288 r10890  
    4242
    4343        return (bool) $result['success'];
     44}
     45
     46/**
     47 * Check the user registration attempt against Akismet.
     48 */
     49function wporg_login_check_akismet( $user_login, $user_email ) {
     50        if ( ! class_exists( 'Akismet' ) ) {
     51                return true;
     52        }
     53
     54        $payload = [
     55                'type'                 => 'user_signup',
     56                'comment_author'       => $user_login,
     57                'comment_author_email' => $user_email,
     58                'comment_post_ID'      => 0,
     59        ];
     60
     61        $akismet = Akismet::rest_auto_check_comment( $c );
     62        if ( is_wp_error( $akismet ) ) {
     63                return $akismet->get_error_code();
     64        }
     65
     66        if ( ! empty( $akismet['akismet_pro_tip'] ) ) {
     67                return $akismet['akismet_pro_tip'];
     68        } elseif ( 'true' === $akismet['akismet_result'] ) {
     69                return 'spam';
     70        } elseif ( 'false' === $akismet['akismet_result'] ) {
     71                return 'OK';
     72        } else {
     73                return 'unsure';
     74        }
    4475}
    4576
    … …  
    88119                        $pending_user['scores']['pending'] = $recaptcha_api['score'];
    89120                }
    90                
    91         }
     121        }
     122
     123        $akismet_says = wporg_login_check_akismet( $user_login, $user_email );
     124        $pending_user['meta']['akismet_result'] = $akismet_says;
    92125
    93126        $inserted = wporg_update_pending_user( $pending_user );
Note: See TracChangeset for help on using the changeset viewer.