Title: Plugins breaks get_users method
Last modified: October 21, 2020

---

# Plugins breaks get_users method

 *  Resolved [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/plugins-breaks-get_users-method/)
 * Hi there,
 * we got a report for our plugin Matomo ( see [https://github.com/matomo-org/wp-matomo/issues/365](https://github.com/matomo-org/wp-matomo/issues/365))
   that approving a member results in an exception triggered by our plugin.
 * After being able to reproduce it and after some debugging session we noticed 
   that the plugin overwrites the `pre_user_query` in the method `filter_users_by_status`
   while approving a user.
 * As a result of this, when we call `get_users([])` in our plugin, then we don’t
   get the list of all users but only one WP user. The user that is being approved.
   This then causes a lot of deletion going on in our plugin since it thinks the
   other WP users were deleted when in reality a filter in your plugin caused this
   issue that not all users were returned.
 * Is there any chance you could adjust your code to not break other plugins? Maybe
   you could add a `um_custom` or some other flag to your `get_users` queries and
   only manipulate the $query_where for your own `get_users` calls like below? This
   way it wouldn’t affect our `get_users` calls. Thanks for considering this!
 *     ```
       	    add_action('pre_user_query', function ($query){
       		    /** @var \WP_User_Query $query */
       		    if ($query->get('um_custom')) {
       			    $query->query_where = '...';
       		    }
       	    });
       	    $options['um_custom'] = '1';
       	    $users_custom = get_users( $options );
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/plugins-breaks-get_users-method/#post-13565548)
 * Hi [@tsteur](https://wordpress.org/support/users/tsteur/)
 * Thanks for letting us know.
 * May i know if your plugin uses `status` variable in the URL to trigger?
 * Our filter query only triggers when the `status` variable is present in the URL
   
   [https://github.com/ultimatemember/ultimatemember/blob/master/includes/admin/core/class-admin-users.php#L332](https://github.com/ultimatemember/ultimatemember/blob/master/includes/admin/core/class-admin-users.php#L332)
 * Regards,
 *  Thread Starter [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/plugins-breaks-get_users-method/#post-13565580)
 * Hi [@champsupertramp](https://wordpress.org/support/users/champsupertramp/) yes
   it basically appends when approving a user/membership feature. Then the status
   variable is present from your plugin basically. We’re listening eg to the `profile_updated`
   hook and then call `get_users` and it then only returns one user.
 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/plugins-breaks-get_users-method/#post-13565700)
 * Hi [@tsteur](https://wordpress.org/support/users/tsteur/)
 * We will change the variable to `um_status` from `status`. We are not able to 
   change the way you want it with the `pre_user_query` because we are attaching
   it to the main `users.php` query. Do you think this should suffice?
 * Regards,
 *  Thread Starter [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/plugins-breaks-get_users-method/#post-13565945)
 * I see. If you can’t change the initial `get_users()` options then it won’t be
   possible to do anything. Changing the query parameter wouldn’t help because when
   the users uses your “approve membership” feature it would then also send the `
   um_status` parameter and the issue be the same. I guess there’s nothing you can
   do in this case then. Thanks though for looking at it.
 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/plugins-breaks-get_users-method/#post-13570999)
 * Hi [@tsteur](https://wordpress.org/support/users/tsteur/)
 * Thanks for letting us know. I am closing this thread now.
 * Regards,

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Plugins breaks get_users method’ is closed to new replies.

 * ![](https://ps.w.org/ultimate-member/assets/icon-256x256.png?rev=3160947)
 * [Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin](https://wordpress.org/plugins/ultimate-member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-member/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-member/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/plugins-breaks-get_users-method/#post-13570999)
 * Status: resolved