[buddypress-trac] [BuddyPress Trac] #7077: Add a global scope option to the BP taxonomy wrapper functions

buddypress-trac noreply at wordpress.org
Sat May 21 01:53:44 UTC 2016


#7077: Add a global scope option to the BP taxonomy wrapper functions
------------------------------+-----------------------------
 Reporter:  rekmla            |       Owner:
     Type:  enhancement       |      Status:  new
 Priority:  normal            |   Milestone:  Future Release
Component:  Component - Core  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |
------------------------------+-----------------------------
Changes (by boonebgorges):

 * milestone:  Awaiting Review => Future Release


Comment:

 @rekmla Thanks for the ticket and the patch.

 The question of where BuddyPress should store taxonomy data is a
 legitimate one. Multinetwork + members is the most obvious case, but there
 are almost certainly other situations where one might legitimately want
 terms from a given BP taxonomy to be stored on one site, and those from
 another taxonomy on a different site.

 For this reason, the suggested patch seems a bit too specific to the
 multinetwork use case. It makes your specific use case very easy - a one-
 line filter - but certain other use cases are difficult.

 A more general solution would be to filter the "term storage blog id". See
 [attachment:7077.2.patch]. (I only applied the necessary changes to
 `bp_set_object_terms()`, but you get the idea.) Your implementation would
 then look like this:

 {{{
 function bp7077_bp_member_type_should_be_stored_on_primary_network(
 $site_id, $taxonomy ) {
     if ( 'bp_member_type' === $taxonomy ) {
         $main_network = wp_get_network( get_main_network_id() );
         $site_id = get_site_by_path( $main_network->domain,
 $main_network->path );
     }

     return $site_id;
 }
 add_filter( 'bp_get_taxonomy_term_site_id',
 'bp7077_bp_member_type_should_be_stored_on_primary_network', 10, 2 );
 }}}

 I've chosen to pass only the `$taxonomy` to the filter, because I'd think
 that in the vast majority of cases, this'll be the determining factor as
 to what gets stored where. But if it'd be useful, `$object_id` could be
 passed as well.

 @rekmla What do you think? Also pinging @johnjamesjacoby, who has done a
 lot of thinking about BP in a multi-network environment.

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


More information about the buddypress-trac mailing list