Making WordPress.org


Ignore:
Timestamp:
09/16/2017 06:23:16 AM (7 years 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-committers.php

    r4301 r5930  
    9292    function add_committer( $request ) {
    9393        $user = new WP_User( $request['committer'] );
    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['committer'] );
     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['committer'] );
     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 revoke_committer( $request ) {
    108119        $user = new WP_User( $request['committer'] );
    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['committer'] );
     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['committer'] );
     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.