Skip to:
Content

bbPress.org

Changeset 6518


Ignore:
Timestamp:
06/10/2017 08:15:37 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Engagements: Update bbp_add_user_object().

  • New phpdoc description
  • Add $unique parameter and default to true (this differs from the normal false default of add_metadata() because, by default, this API assumes no 1 user can have multiple relationships with the same object)
  • Pass $unique into apply_filters()

See #3068.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/engagements.php

    r6517 r6518  
    1414
    1515/**
    16  * Set a user id on an object
     16 * Add a user id to an object
    1717 *
    1818 * @since 2.6.0 bbPress (r6109)
     
    2222 * @param string $meta_key  The relationship key
    2323 * @param string $meta_type The relationship type
     24 * @param bool   $unique    Whether metadata should be unique to the object
    2425 *
    2526 * @uses add_post_meta() To set the term on the object
    26  * @uses apply_filters() Calls 'bbp_add_user_to_object' with the object id, user
    27  *                        id, and taxonomy
    28  * @return bool Returns true if the user taxonomy term is added to the object,
    29  *               otherwise false
    30  */
    31 function bbp_add_user_to_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
    32     $retval = add_metadata( $meta_type, $object_id, $meta_key, $user_id, false );
    33 
    34     // Filter & return
    35     return (bool) apply_filters( 'bbp_add_user_to_object', (bool) $retval, $object_id, $user_id, $meta_key, $meta_type );
     27 * @uses apply_filters() Calls 'bbp_add_user_to_object' with the return value & parameters
     28 * @return bool Returns true if the user is added to the object, otherwise false
     29 */
     30function bbp_add_user_to_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post', $unique = true ) {
     31    $retval = add_metadata( $meta_type, $object_id, $meta_key, $user_id, $unique );
     32
     33    // Filter & return
     34    return (bool) apply_filters( 'bbp_add_user_to_object', (bool) $retval, $object_id, $user_id, $meta_key, $meta_type, $unique );
    3635}
    3736
Note: See TracChangeset for help on using the changeset viewer.