stuttter / wp-user-groups

Group users together with taxonomies & terms
https://wordpress.org/plugins/wp-user-groups/
GNU General Public License v2.0
48 stars 22 forks source link

Incorrect user numbers on taxonomy overview #8

Closed ms-studio closed 6 years ago

ms-studio commented 7 years ago

I noticed a weird thing occurring quite systematically with my user-groups:

On the edit-tags.php?taxonomy=user-group overview, the number stated for each group has one value more than the number of actual users displayed when navigating the group.

For instance, in the table view, one of my groups shows 13 users:

user-group-number

But when I go to the user listing, there are only 12 users in the group.

The reason for the mismatch: there's a "zero" included in the array of user IDs. If I do get_objects_in_term() for that group, here's what I see:

array (size=13)
  0 => string '0' (length=1)
  1 => string '3' (length=1)
  2 => string '4' (length=1)
  3 => string '33' (length=2)
  4 => string '53' (length=2)
  5 => string '60' (length=2)
  6 => string '203' (length=3)
  7 => string '208' (length=3)
  8 => string '218' (length=3)
  9 => string '342' (length=3)
  10 => string '375' (length=3)
  11 => string '435' (length=3)
  12 => string '597' (length=3)

Notice the zero in the first line! I'm not sure if there's a bug in my method of automatically populating the user-groups (very possible), or if the issue is in the plugin itself.

In my custom code, my workaround is to use array_filter() before displaying data related to the user-groups.

JJJ commented 7 years ago

Hey @ms-studio, this sure is weird. I've used this plugin on about 10 different projects, and have not run into this as an issue yet.

My guess, politely, is that it's a bug in your auto-populate code.

The built in wp_get_users_of_group() function uses get_objects_in_term() internally, so it will likely exhibit the same problem.

I'll leave this issue open for a bit, until we have confirmation one way or the other.

ms-studio commented 7 years ago

Hey @JJJ, thanks for the follow-up. It's very possible indeed that the issue was caused by my custom code.

JJJ commented 6 years ago

Closing this. If it needs to be reopened, please feel free!