Making WordPress.org

Changeset 10929


Ignore:
Timestamp:
04/27/2021 04:44:30 AM (4 years ago)
Author:
dd32
Message:

Helpscout: Search pending signups for the email address in addition to accounts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/profile.php

    r10909 r10929  
    1414    $user = get_user_by( 'email', $request->customer->email );
    1515    if ( isset( $user->user_nicename ) ) {
    16         $html .= '<p>Profile: <a href="https://profiles.wordpress.org/' . $user->user_nicename . '">'. $user->user_nicename .'</a></p>';
    17         $html .= '<p>Forums: <a href="https://wordpress.org/support/users/'. $user->user_nicename . '">'. $user->user_nicename .'</a></p>';
     16        $html .= '<p>Profile: <a href="https://profiles.wordpress.org/' . $user->user_nicename . '/">'. $user->user_nicename .'</a></p>';
     17        $html .= '<p>Forums: <a href="https://wordpress.org/support/users/'. $user->user_nicename . '/">'. $user->user_nicename .'</a></p>';
    1818    } else {
    1919        $html .= '<p>No profile found</p>';
    2020    }
     21
     22    // See if they have a pending user account.
     23    $records = $wpdb->get_results( $wpdb->prepare(
     24        "SELECT * FROM {$wpdb->base_prefix}user_pending_registrations
     25        WHERE user_email = %s OR user_email LIKE %s",
     26        $request->customer->email,
     27        str_replace( '@', '+%@', $wpdb->esc_like( $request->customer->email ) ) // Handle plus addressing.
     28    ) );
     29    if ( $records ) {
     30        $html .= '<p>Signups found:</p>';
     31        $html .= '<ul>';
     32
     33        $match_status = function( $u ) {
     34            if ( $u->created ) {
     35                return 'Created';
     36            }
     37            if ( ! $u->cleared ) {
     38                return 'Caught in Spam';
     39            }
     40            return 'Pending';
     41        };
     42
     43        foreach ( $records as $u ) {
     44            $html .= sprintf(
     45                '<li><a href="%s">%s <strong>%s</strong></a></li>',
     46                esc_url( add_query_arg( 's', urlencode( $u->user_email ), 'https://login.wordpress.org/wp-admin/index.php?page=user-registrations&s=' ) ),
     47                esc_html( $u->user_login ) . (
     48                    $request->customer->email == $u->user_email ? '' : ' (' . esc_html( $u->user_email ) . ')'
     49                ),
     50                esc_html( $match_status( $u ) )
     51            );
     52        }
     53
     54        $html .= '</ul>';
     55    }
     56
     57    $html .= sprintf(
     58        '<p><a href="%s">Search pending signups</a></p>',
     59        esc_url( add_query_arg( 's', urlencode( $request->customer->email ), 'https://login.wordpress.org/wp-admin/index.php?page=user-registrations&s=' ) ),
     60    );
    2161
    2262}
Note: See TracChangeset for help on using the changeset viewer.