Skip to:
Content

BuddyPress.org

Ticket #6188: 6188-bp_remove_object_terms.diff

File 6188-bp_remove_object_terms.diff, 1.6 KB (added by Mamaduka, 6 years ago)
  • src/bp-core/bp-core-taxonomy.php

    diff --git src/bp-core/bp-core-taxonomy.php src/bp-core/bp-core-taxonomy.php
    index da68e04..1573157 100644
    function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) { 
    7979
    8080        return $retval;
    8181}
     82
     83/**
     84 * Remove taxonomy terms on a BuddyPress object.
     85 *
     86 * @since BuddyPress (2.3.0)
     87 *
     88 * @see wp_remove_object_terms() for a full description of function and parameters.
     89 *
     90 * @param int          $object_id Object ID.
     91 * @param string|array $terms     Term or terms to remove.
     92 * @param string       $taxonomy  Taxonomy name.
     93 * @return bool|WP_Error True on success, false or WP_Error on failure.
     94 */
     95function bp_remove_object_terms( $object_id, $terms, $taxonomy ) {
     96        $is_root_blog = bp_is_root_blog();
     97
     98        if ( ! $is_root_blog ) {
     99                switch_to_blog( bp_get_root_blog_id() );
     100        }
     101
     102        $retval = wp_remove_object_terms( $object_id, $terms, $taxonomy );
     103
     104        if ( ! $is_root_blog ) {
     105                restore_current_blog();
     106        }
     107
     108        return $retval;
     109}
     110 No newline at end of file
  • src/bp-members/bp-members-functions.php

    diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php
    index 1abbc8f..346e7f9 100644
    function bp_remove_member_type( $user_id, $member_type ) { 
    26162616                return false;
    26172617        }
    26182618
    2619         $deleted = wp_remove_object_terms( $user_id, $member_type, 'bp_member_type' );
     2619        $deleted = bp_remove_object_terms( $user_id, $member_type, 'bp_member_type' );
    26202620
    26212621        // Bust the cache if the type has been removed.
    26222622        if ( ! is_wp_error( $deleted ) ) {