[buddypress-trac] [BuddyPress Trac] #6060: Display and filter by member type on Dashboard > Users

buddypress-trac noreply at wordpress.org
Wed Sep 14 02:15:49 UTC 2016


#6060: Display and filter by member type on Dashboard > Users
--------------------------------------+-----------------------
 Reporter:  boonebgorges              |       Owner:  slaFFik
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  2.7
Component:  Members                   |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  good-first-bug has-patch  |
--------------------------------------+-----------------------

Comment (by boonebgorges):

 > What's the best way to find all the users of a particular type? The code
 currently uses get_objects_in_term() but maybe doing a BP_User_Query would
 be better?

 A `BP_User_Query` will require more resources, and will also require some
 work to avoid recursion (since a `BP_User_Query` eventually calls
 'pre_get_users'). If `BP_User_Query` had enough caching that we could
 avoid hitting the database, I'd say we should switch to it. Since that's
 not currently the case, `get_objects_in_term()` seems like a simpler
 approach.

 > The general WP function translate_user_role() is used on the member type
 name at output, but I'm not sure it will have an effect.

 It definitely won't do anything in this context, since
 `translate_user_role()` assumes the default domain, not `buddypress`. BP
 member types work differently from WP roles since they're fully defined in
 code, so I'd say we can leave this out for now. If it turns out that parts
 are untranslatable after 2.7, we'll look at what hoops we need to jump
 through to fix it.

 >  The function users_type_change_to() relies on a passed parameter $which
 to know whether the control is above or below the table. This parameter
 wasn't passed to the action hook until WP 4.6, so in 4.5 and earlier, the
 upper dropdown's input never works (it has the same name as the lower, so
 it's overwritten in the $_REQUEST). Is there anything we can do to make
 this work in 4.5 and earlier? Short of a global variable, I'm not sure how
 to output the control only once in earlier versions.

 Meh, I wouldn't go to too much trouble to make this work in earlier
 versions. Only displaying it once (at the top) seems like it'd be fine in
 this case. Something like:

 {{{
 public function users_table_output_type_change_select( $which ) {
     static $displayed;

     if ( version_compare( bp_get_major_wp_version(), '4.5', '<' ) && !
 empty( $displayed ) ) {
         return;
     }

     $displayed = true;

     ...
 }}}

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6060#comment:17>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list