• I’ve run into a very odd conflict between this plugin and WP Security Audit Log (premium version only, not sure why).

    When both plugins are active, filtering by unapproved users only causes no results to be displayed. It appears somewhere along the line during WP_User_Query::prepare_query(), the WPSAL plugin reverts the pre_user_query hook, undoing the mapping of wpau_unapproved role to wp-approve-user meta_key.

    I’ve yet to find the exact cause in WPSAL, but I think it can be safely fixed in Approve User by moving the pre_user_query hook to the pre_get_users hook (why these hooks aren’t called in WordPress the other way around is beyond me). This hook is runs before the query vars are parsed, making it a better location to update the query vars without needing to re-call prepare_query(), which I’m certain is where the bug lies.

    I’m able to non-destructively patch it using my own mini-plugin:

    
    remove_filter( 'pre_user_query', array( Obenland_Wp_Approve_User::$instance, 'pre_user_query' ) );
    
    function wp_approve_user_handle_unapproved_role( $query ) {
    	$role = empty( $query->query_vars['role'] ) && isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : $query->query_vars['role'];
    
    	if ( 'wpau_unapproved' === $role ) {
    		unset( $query->query_vars['meta_query'] );
    		$query->query_vars['role'] = '';
    		$query->query_vars['meta_key'] = 'wp-approve-user';
    		$query->query_vars['meta_value'] = false;
    	}
    }
    add_filter( 'pre_get_users', 'wp_approve_user_handle_unapproved_role' );
    
Viewing 1 replies (of 1 total)
  • Thanks for sharing your code Doug – this resolved an issue we were having on one of our sites. iThemes Security Pro, which has similar security auditing, is also causing this issue where the unapproved user list was blank.

Viewing 1 replies (of 1 total)
  • The topic ‘Odd conflict with WP Security Audit Log (Premium)’ is closed to new replies.