Skip to:
Content
Pages
Categories
Search
Top
Bottom

Active members counts do not match


  • Oscar Estepa
    Participant

    @estepix

    Hi I’m developing a site for a client and I might have found a bug, not sure yet.

    The thing is that I get two different values for the active members count when accessing the Members page, one for the All Members string and a different one for Viewing member n to N (of M active member). I leave the strings ids below for reference.

    After some debugging I found out that these values come from very different functions:

    • All Members count is returned from the function bp_core_get_active_member_count() (L583: wp-content/plugins/buddypress/bp-members/bp-members-functions.php)
    • Viewing member n to N (of M active member) is set in function do_user_ids_query (L433: wp-content/plugins/buddypress/bp-core/bp-core-classes.php). To save you some tracing, do_user_ids_query is called by BP_User_Query::__construct (L175: wp-content/plugins/buddypress/bp-core/bp-core-classes.php), called by bp_core_get_users (L106: wp-content/plugins/buddypress/bp-members/bp-members-functions.php), called by BP_Core_Members_Template::__construct (L181: wp-content/plugins/buddypress/bp-members/bp-members-template.php
      </u>

      The SQL query run by these two functions is different and return different values when a user is not active (in my case I have some users with user_status=2), the first showing the correct value and the second the wrong one since it does not take into account “user_status”

      • All Members – CORRECT COUNT. Query: SELECT COUNT(user_id) FROM wp_bp_activity WHERE component = ‘members’ AND type = ‘last_activity’ AND user_id NOT IN ($exclude_users_sql).
      • Viewing member n to N (of M active member) – WRONG COUNT. Query: SELECT COUNT(u.user_id) FROM wp_bp_activity u WHERE u.component = ‘members’ AND u.type = ‘last_activity’.

      Shouldn’t these two values be retrieved using the same function?

      Also, it would be great if a filter hook was added to bp_core_get_active_member_count to allow users to set the expiration time of the transient, right now it is 0 by default which in a live site where information is updated constantly doesn’t make much sense. I found a workaround for this using apply_filters( ‘bp_core_get_active_member_count’, $count ) but it would be easier if we were allowed to change the transient expiration time.

      String IDs

      
      #: bp-templates/bp-legacy/buddypress/activity/index.php:19
      #: bp-templates/bp-legacy/buddypress/members/index.php:19
      #: bp-themes/bp-default/activity/index.php:39
      #: bp-themes/bp-default/members/index.php:35
      #, php-format
      #@ buddypress
      msgid "All Members <span>%s</span>"
      
      
      #: bp-members/bp-members-template.php:347
      #, php-format
      #@ buddypress
      msgid "Viewing member %1$s to %2$s (of %3$s active member)"
      
  • The topic ‘Active members counts do not match’ is closed to new replies.
Skip to toolbar