Skip to:
Content

bbPress.org

Changeset 6519


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

Moderators: Add an $object_type parameter to add/remove/delete functions.

In a future release, this will more easily allow objects like taxonomy-terms to have their own moderators, and is also necessary for future enhancements to the WordPress.org support forums where custom taxonomies are used for prevalently than in bbPress core currently.

See #3068, #459.

File:
1 edited

Legend:

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

    r6438 r6519  
    798798 * Add a moderator to an object
    799799 *
    800  * @since 2.6.0 bbPRess
    801  *
    802  * @param int $object_id Traditionally a forum ID, but could be useful
    803  * @param int $user_id
    804  *
    805  * @return @mixed
    806  */
    807 function bbp_add_moderator( $object_id = 0, $user_id = 0 ) {
    808     return bbp_add_user_to_object( $object_id, $user_id, '_bbp_moderator_id' );
     800 * @since 2.6.0 bbPress (r6056)
     801 *
     802 * @param int    $object_id   Traditionally a post ID
     803 * @param int    $user_id     User ID
     804 * @param string $object_type Type of meta (post,term,user,comment)
     805 *
     806 * @return bool
     807 */
     808function bbp_add_moderator( $object_id = 0, $user_id = 0, $object_type = 'post' ) {
     809    return bbp_add_user_to_object( $object_id, $user_id, '_bbp_moderator_id', $object_type );
    809810}
    810811
     
    812813 * Remove a moderator user ID from an object
    813814 *
    814  * @since 2.6.0 bbPress
    815  *
    816  * @param int $object_id
    817  * @param int $user_id
     815 * @since 2.6.0 bbPress (r6056)
     816 *
     817 * @param int    $object_id   Traditionally a post ID
     818 * @param int    $user_id     User ID
     819 * @param string $object_type Type of meta (post,term,user,comment)
    818820 *
    819821 * @return bool
    820822 */
    821 function bbp_remove_moderator( $object_id = 0, $user_id = 0 ) {
    822     return bbp_remove_user_from_object( $object_id, $user_id, '_bbp_moderator_id' );
     823function bbp_remove_moderator( $object_id = 0, $user_id = 0, $object_type = 'post' ) {
     824    return bbp_remove_user_from_object( $object_id, $user_id, '_bbp_moderator_id', $object_type );
    823825}
    824826
     
    826828 * Get user IDs of moderators for an object
    827829 *
    828  * @since 2.6.0 bbPress
    829  *
    830  * @param int $object_id
    831  *
    832  * @return mixed
    833  */
    834 function bbp_get_moderator_ids( $object_id = 0 ) {
    835     return bbp_get_users_for_object( $object_id, '_bbp_moderator_id' );
     830 * @since 2.6.0 bbPress (r6056)
     831 *
     832 * @param int    $object_id   Traditionally a post ID
     833 * @param string $object_type Type of meta (post,term,user,comment)
     834 *
     835 * @return array
     836 */
     837function bbp_get_moderator_ids( $object_id = 0, $object_type = 'post' ) {
     838    return bbp_get_users_for_object( $object_id, '_bbp_moderator_id', $object_type );
    836839}
    837840
     
    840843 * object ID is empty.
    841844 *
    842  * @since 2.6.0 bbPress
    843  *
    844  * @param int $object_id
     845 * @since 2.6.0 bbPress (r6056)
     846 *
     847 * @param int    $object_id   Traditionally a post ID
     848 * @param string $object_type Type of meta (post,term,user,comment)
    845849 *
    846850 * @return array
    847851 */
    848 function bbp_get_moderators( $object_id = 0 ) {
     852function bbp_get_moderators( $object_id = 0, $object_type = 'post' ) {
    849853
    850854    // Get global moderators
     
    857861    } else {
    858862        $users = get_users( array(
    859             'include' => bbp_get_moderator_ids( $object_id ),
     863            'include' => bbp_get_moderator_ids( $object_id, $object_type ),
    860864        ) );
    861865    }
    862866
    863867    // Filter & return
    864     return (array) apply_filters( 'bbp_get_moderators', $users, $object_id );
    865 }
     868    return (array) apply_filters( 'bbp_get_moderators', $users, $object_id, $object_type );
     869}
Note: See TracChangeset for help on using the changeset viewer.