[wp-trac] [WordPress Trac] #49416: Deleting a user when having thousands of users

WordPress Trac noreply at wordpress.org
Sun Sep 6 16:53:23 UTC 2020


#49416: Deleting a user when having thousands of users
--------------------------+------------------------------------------
 Reporter:  alexjones     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Users         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  administration, performance
--------------------------+------------------------------------------

Comment (by Mista-Flo):

 That's an interesting ticket, I'm not sure why the user-suggest.js is only
 used on multisite. In the AJAX action, you have this code:
 {{{#!php
 <?php
         if ( ! is_multisite() || ! current_user_can( 'promote_users' ) ||
 wp_is_large_network( 'users' ) )

         if ( ! current_user_can( 'manage_network_users' ) && !
 apply_filters( 'autocomplete_users_for_site_admins', false ) )
 }}}

 If I just comment these two if states, create a new input text in

 {{{#!php
 <?php

                 if ( $users_have_content ) {
                         add_action( 'admin_head', 'delete_users_add_js' );

                         wp_enqueue_script( 'jquery-ui-autocomplete' );
                         wp_enqueue_script( 'user-suggest' );
                 }

 -------

                                 <input type="text" id="reassign_user_new"
 class="wp-suggest-user" name="reassign_user_new" data-autocomplete-
 type="search" />


 }}}

 It works well. Of course, you would need to update a bit because a user ID
 is expected by the original field, and I would prefer to use the REST API,
 but it can do the trick.

 I don't understand why in multisite it doesn't accept the suggestion if
 it's a large network, does that mean you have to enter the exact
 email/username of the user without any possible search?

 I have also tried another implementation, by looking at tags-suggest.js
 (but it's still a draft, the suggestions are not displayed), so given an
 input text field:


 {{{
         var user_endpoint = '<?php echo rest_url('wp/v2/users/'); ?>';
         var cache = {};
         $( "#reassign_user_new" ).autocomplete({
                 minLength: 2,
                 source: function( request, response ) {
                         var term = request.term;
                         console.log( term );
                         console.log( cache );
                         if ( term in cache ) {
                                 response( cache[ term ] );
                                 return;
                         }

                         console.log( user_endpoint + '?search=' + term );

                         $.getJSON( user_endpoint + '?search=' + term,
 request, function( data, status, xhr ) {
                                 cache[ term ] = data;
                                 response( data );
                         });
                 }
         });
 }}}

 What's your thoughts on this? I can definitely see some possible
 implementations around the admin, like the privacy page dropdown, what if
 you have thousands of pages?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49416#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list