• Resolved Thomas

    (@tsteur)


    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_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

    (@champsupertramp)

    Hi @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

    Regards,

    Thread Starter Thomas

    (@tsteur)

    Hi @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

    (@champsupertramp)

    Hi @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

    (@tsteur)

    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

    (@champsupertramp)

    Hi @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.