Support » Plugin: WP Approve User » Multisite – issues with user lists and “unapproved” filter

  • Resolved naomir

    (@naomir)


    Hi, I’m using multisite and having the following issues. When there are some unapproved users, if I go to Network -> Users or to the user list of the site they have signed up to, an option appears to filter the list by “Unapproved”. But it does not work. On the Network list it does not appear to filter the list at all, and returns all the users. On an individual site, it returns no users. I can have a look at this and try to debug it if you like.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Konstantin Obenland

    (@obenland)

    That would be fantastic @naomir, thank you!

    Hi @obenland I have made some progress with this.

    It’s a bit of a hack, because I admit I don’t understand how the user query object works and how this code interacts with core.

    The results are not perfect because if you use it on a subsite it still shows you all the unapproved users from all sites. But hopefully it is a useful starting point.

    I’ve wrapped the changes in if is_multisite() based on the assumption that the existing code works for normal sites. This assumption may be wrong of course.

      public function pre_user_query( $query ) {
        // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification, WordPress.VIP.ValidatedSanitizedInput
        $role = empty( $query->query_vars['role'] ) && isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : $query->query_vars['role'];
    
        if ( 'wpau_unapproved' === $role ) {      
          if(is_multisite()) {
            global $wpdb;
            $users = $wpdb->base_prefix . 'users';
            $usermeta = $wpdb->base_prefix . 'usermeta';
            $query->query_from = "FROM $users INNER JOIN $usermeta ON ( $users.ID = $usermeta.user_id )";
            $query->query_where = "WHERE $usermeta.meta_key = 'wp-approve-user' AND $usermeta.meta_value = FALSE";
          } else {
            unset( $query->query_vars['meta_query'] );
            $query->query_vars['role']       = '';
            $query->query_vars['meta_key']   = 'wp-approve-user';
            $query->query_vars['meta_value'] = false;
            remove_filter( 'pre_user_query', array( $this, 'pre_user_query' ) );
            $query->prepare_query();
          }
        }
      }
    Plugin Author Konstantin Obenland

    (@obenland)

    I just pushed out an update that should fix the issue. Thanks for the heads up and your work on it!

    naomir

    (@naomir)

    I have the latest version and I am afraid it’s still not working. But I just put my fix back in and it is OK again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.