WordPress.org

Making WordPress.org


Ignore:
Timestamp:
09/16/2017 06:23:16 AM (10 months ago)
Author:
SergeyBiryukov
Message:

Plugin Directory: Allow for adding committers and support reps by a slug or email, as the input suggests.

Fixes #3133. See #3029.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-support-reps.php

    r5867 r5930  
    9292    function add_support_rep( $request ) {
    9393        $user = new WP_User( $request['support_rep'] );
    94         if ( ! $user->exists() ) {
     94
     95        // If user_login is not found, try searching by user_nicename.
     96        if ( ! $user || ! $user->exists() ) {
     97            $user = get_user_by( 'slug', $request['support_rep'] );
     98        }
     99
     100        // If user_nicename is not found, try searching by user_email.
     101        if ( ! $user || ! $user->exists() ) {
     102            $user = get_user_by( 'email', $request['support_rep'] );
     103        }
     104
     105        if ( ! $user || ! $user->exists() ) {
    95106            return new WP_Error( 'plugin_user_not_found', __( 'The provided user could not be found.', 'wporg-plugins' ) );
    96107        }
     
    107118    function remove_support_rep( $request ) {
    108119        $user = new WP_User( $request['support_rep'] );
    109         if ( ! $user->exists() ) {
     120
     121        // If user_login is not found, try searching by user_nicename.
     122        if ( ! $user || ! $user->exists() ) {
     123            $user = get_user_by( 'slug', $request['support_rep'] );
     124        }
     125
     126        // If user_nicename is not found, try searching by user_email.
     127        if ( ! $user || ! $user->exists() ) {
     128            $user = get_user_by( 'email', $request['support_rep'] );
     129        }
     130
     131        if ( ! $user || ! $user->exists() ) {
    110132            return new WP_Error( 'plugin_user_not_found', __( 'The provided user could not be found.', 'wporg-plugins' ) );
    111133        }
Note: See TracChangeset for help on using the changeset viewer.