• When you delete an user in the next page you are shown an option to reassign the user’s articles to another user through a SELECT html control filled with all users.

    My installation has a LOT of users and WordPress doesn’t manage to fill the select, I suppose because memory exhausted or whatever.

    I think it would be wise to at least not fill this SELECT unless I click the radio button to choose to reassign and fill it via ajax, or to study another way in case of too many users maybe by inserting manually the user ID to replace.

    I wonder if there’s any hook to disable this thing, I hate to edit the WP core in order to fix this.

Viewing 5 replies - 1 through 5 (of 5 total)
  • How many users are we talking about here?

    Thread Starter DrLightman

    (@drlightman)

    About 330’000

    Oh boy! That’s a lot of users! To be honest, I’m not sure how well (or not) WordPress scales up for that kind of registered user base. I think your best bet initially, is to post in the Hacks forum for advice on a hook that you can use to disable the dropdown.

    You might also want to join the wp-hackers mailing list. That’s where some of the enterprise level heavyweights hang out. If anyone can give you tips on managing such a large user base, those guys can.

    Thread Starter DrLightman

    (@drlightman)

    Thanks!

    I’m a little late to the thread, but for all those who run into the same problem, here’s how I solved it.

    I was experiencing the same memory errors when the Delete Users page tried to query all 289,000+ users at once, so I wrote the following filter to limit the query to Authors, or more specifically, users with the role of Contributor and above, since those are the only users on my site that will have posts attributed to them anyway.

    /**
     * Filters the query that grabs all users in the database for the Select field on the Delete Users page,
     * restricting the query to Contributors and above
     */
    function delete_user_select_only_authors( $query ) {
    	// make sure we are on the Delete Users page
    	if ('/wp-admin/users.php' == $_SERVER['PHP_SELF'] && isset($_GET['action']) && 'delete' == $_GET['action']) {
    		global $wpdb;
    		// grabbing table names for convenience, taking into account custom prefix
    		$users = $wpdb->users;
    		$usermeta = $wpdb->usermeta;
    		$id = $_GET['user'];
    		// only alter the query attempting to select all users in the database
    		if ($query == "SELECT $users.ID,$users.display_name FROM $users WHERE 1=1 AND $users.ID NOT IN ($id) ORDER BY display_name ASC ") {
    			// create a replacement WHERE clause to select only Contributors and above
    			$join_where = "JOIN $usermeta ON $users.ID = $usermeta.user_id WHERE $usermeta.meta_key = 'wp_user_level' AND $usermeta.meta_value > 0";
    			// replace the new WHERE in the original query
    			$query = str_replace('WHERE 1=1', $join_where, $query);
    		}
    	}
    	return $query;
    }
    add_filter( 'query', 'delete_user_select_only_authors' );
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp-admin, deleting an user, crashes because of too many users’ is closed to new replies.