Skip to:

Opened 7 years ago

Closed 7 years ago

#6813 closed defect (bug) (fixed)

Count & no-count classes not working properly for Groups

Reported by: wp_new_user's profile wp_new_user Owned by: boonebgorges's profile boonebgorges
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.4.0
Component: Groups Keywords:



In the in the user profile main navigation there are numbers next to each tab (like groups, messages etc.) showing the total number of groups, messages etc.
When they are 0, the <span> has a class="no-count", when not 0, class="count".
However, for the Groups, though the number is 0, the <span> class is still "count".

My website is not translated and is in English only.
I have tried checked on multiple themes, including WP Twenty themes, the problem exists anyway.

I have deactivated/removed all the plugins, the problem exists anyway.

Levon Avetyan

P.S. my BuddyPress version is 2.4.3 (there's no option like that below)

P.S.S. I can still live without groups tab 0 span class=no-count, just was advised me to open a ticket here, so hope it helps.

Change History (5)

#1 @DJPaul
7 years ago

Related to

I don't think this has been confirmed yet, so someone needs to check against trunk. I though we had a fix for something like this in 2.4

#2 @boonebgorges
7 years ago

  • Component changed from API to Component - Groups
  • Milestone changed from Awaiting Review to 2.5

The 'count' and 'no-count' classes were introduced in [7758].

The problem is that the check is strict 0 === $count, but $count is a string. As far as I can see, this issue has always existed. bp_get_total_group_count_for_user(), groups_total_groups_for_user(), and BP_Groups_Member::total_group_count() all claim in their documentation to return integers, but none of them do.

There's a possibility for some breakage, but I recommend we fix this by casting the return values of all of these functions to integers. (We have to do all of them because of the filters and cache support.) I'm going to make the change and see if anyone complains about it :)

#3 @boonebgorges
7 years ago

Actually, it looks like bp_get_total_group_count_for_user() can't be an integer, because it's run through bp_core_number_format(). We should use groups_total_groups_for_user() to set the count class.

#4 @boonebgorges
7 years ago

In 10444:

Correct @return documentation for bp_get_total_group_count_for_user().

The return value of this function is run through bp_core_number_format(),
which means it'll always be a string.

See #6813.

#5 @boonebgorges
7 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 10445:

Use unformatted group count when deciding whether to use the 'no-count' in user nav.

A number of problems can arise when using a formatted group count for this
comparison, because formatted counts are strings.

Fixes #6813.

Note: See TracTickets for help on using tickets.