bp_set_object_terms( int $object_id, string|array $terms, string $taxonomy, bool $append = false )
Set taxonomy terms on a BuddyPress object.
Description Description
See also See also
- wp_set_object_terms(): for a full description of function and parameters.
Parameters Parameters
- $object_id
-
(Required) Object ID.
- $terms
-
(Required) Term or terms to set.
- $taxonomy
-
(Required) Taxonomy name.
- $append
-
(Optional) True to append terms to existing terms. Default: false.
Default value: false
Return Return
(array) Array of term taxonomy IDs.
Source Source
File: bp-core/bp-core-taxonomy.php
function bp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
$site_id = bp_get_taxonomy_term_site_id( $taxonomy );
$switched = false;
if ( $site_id !== get_current_blog_id() ) {
switch_to_blog( $site_id );
bp_register_taxonomies();
$switched = true;
}
$tt_ids = wp_set_object_terms( $object_id, $terms, $taxonomy, $append );
if ( $switched ) {
restore_current_blog();
}
/**
* Fires when taxonomy terms have been set on BuddyPress objects.
*
* @since 2.7.0
*
* @param int $object_id Object ID.
* @param array $terms Term or terms to remove.
* @param array $tt_ids Array of term taxonomy IDs.
* @param string $taxonomy Taxonomy name.
*/
do_action( 'bp_set_object_terms', $object_id, $terms, $tt_ids, $taxonomy );
return $tt_ids;
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.2.0 | Introduced. |