BBP_User_Engagements_Term::get_users_for_object( int $object_id, string $meta_key = '', string $meta_type = 'post' )
Get users of an object
Description Description
Parameters Parameters
- $object_id
-
(Required) The object id
- $meta_key
-
(Optional) The key used to index this relationship
Default value: ''
- $meta_type
-
(Optional) The type of meta to look in
Default value: 'post'
Return Return
(array) Returns ids of users
Source Source
File: includes/common/engagements.php
public function get_users_for_object( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
$user_key = "{$meta_key}_user_id_";
$tax_key = "{$meta_key}_{$meta_type}";
$this->jit_taxonomy( $tax_key );
// Get terms
$terms = get_terms( array(
'object_ids' => $object_id,
'taxonomy' => $tax_key
) );
// Slug part to replace
$user_ids = array();
// Loop through terms and get the user ID
foreach ( $terms as $term ) {
$user_ids[] = str_replace( $user_key, '', $term->slug );
}
// Parse & return
return wp_parse_id_list( $user_ids );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |