Changeset 6422 for trunk/src/includes/users/functions.php
- Timestamp:
- 05/22/2017 06:09:16 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/functions.php
r6421 r6422 183 183 184 184 return apply_filters( 'bbp_current_author_ua', $retval ); 185 }186 187 /** User Relationships ********************************************************/188 189 /**190 * Set a user id on an object191 *192 * @since 2.6.0 bbPress(r6109)193 *194 * @param int $object_id The object id195 * @param int $user_id The user id196 * @param string $meta_key The relationship key197 * @param string $meta_type The relationship type198 *199 * @uses add_post_meta() To set the term on the object200 * @uses apply_filters() Calls 'bbp_add_user_to_object' with the object id, user201 * id, and taxonomy202 * @return bool Returns true if the user taxonomy term is added to the object,203 * otherwise false204 */205 function bbp_add_user_to_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {206 $retval = add_metadata( $meta_type, $object_id, $meta_key, $user_id, false );207 208 return (bool) apply_filters( 'bbp_add_user_to_object', (bool) $retval, $object_id, $user_id, $meta_key, $meta_type );209 }210 211 /**212 * Remove a user id from an object213 *214 * @since 2.6.0 bbPress(r6109)215 *216 * @param int $object_id The post id217 * @param int $user_id The user id218 * @param string $meta_key The relationship key219 * @param string $meta_type The relationship type220 *221 * @uses delete_post_meta() To remove the term from the object222 * @uses apply_filters() Calls 'bbp_remove_user_from_object' with the object223 * id, user id, and taxonomy224 * @return bool Returns true is the user taxonomy term is removed from the object,225 * otherwise false226 */227 function bbp_remove_user_from_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {228 $retval = delete_metadata( $meta_type, $object_id, $meta_key, $user_id, false );229 230 return (bool) apply_filters( 'bbp_remove_user_from_object', (bool) $retval, $object_id, $user_id, $meta_key, $meta_type );231 }232 233 /**234 * Get user taxonomy terms for an object235 *236 * @since 2.6.0 bbPress(r6109)237 *238 * @param int $object_id The object id239 * @param string $meta_key The key used to index this relationship240 * @param string $meta_type The type of meta to look in241 *242 * @uses get_post_meta() To get the user taxonomy terms243 * @uses apply_filters() Calls 'bbp_get_users_for_object' with the user244 * taxonomy terms, object id, and taxonomy245 * @return array Returns the user taxonomy terms of the object246 */247 function bbp_get_users_for_object( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {248 $meta = get_metadata( $meta_type, $object_id, $meta_key, false );249 $retval = wp_parse_id_list( $meta );250 251 return (array) apply_filters( 'bbp_get_users_for_object', (array) $retval, $object_id, $meta_key, $meta_type );252 }253 254 /**255 * Check if the user id is set on an object256 *257 * @since 2.6.0 bbPress(r6109)258 *259 * @param int $object_id The object id260 * @param int $user_id The user id261 * @param string $meta_key The relationship key262 * @param string $meta_type The relationship type263 *264 * @uses get_post_meta() To check if the user id is set on the object265 * @uses apply_filters() Calls 'bbp_is_object_of_user' with the object id,266 * user id, and taxonomy267 * @return bool Returns true if the user id is set on the object for the268 * taxonomy, otherwise false269 */270 function bbp_is_object_of_user( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {271 $user_ids = bbp_get_users_for_object( $object_id, $meta_key, $meta_type );272 $retval = is_numeric( array_search( $user_id, $user_ids, true ) );273 274 return (bool) apply_filters( 'bbp_is_object_of_user', (bool) $retval, $object_id, $user_id, $meta_key, $meta_type );275 185 } 276 186
Note: See TracChangeset
for help on using the changeset viewer.