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 ) 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_queryin the methodfilter_users_by_statuswhile 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_customor some other flag to yourget_usersqueries and only manipulate the $query_where for your ownget_userscalls like below? This way it wouldn’t affect ourget_userscalls. 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 );
The topic ‘Plugins breaks get_users method’ is closed to new replies.