Changeset 6056 for trunk/src/includes/users/capabilities.php
- Timestamp:
- 06/05/2016 06:27:54 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/capabilities.php
r5951 r6056 26 26 * @uses bbp_get_reply_post_type() To get the reply post type 27 27 * @uses bbp_get_reply_forum_id() To get the reply forum id 28 * @uses bbp_is_user_forum_mod () To check if the user is a forum moderator28 * @uses bbp_is_user_forum_moderator() To check if the user is a forum moderator 29 29 * @uses apply_filters() Filter mapped results 30 30 * … … 110 110 111 111 // If user is a per-forum moderator, make sure they can spectate. 112 if ( bbp_is_user_forum_mod ( $user_id, $forum_id ) ) {112 if ( bbp_is_user_forum_moderator( $user_id, $forum_id ) ) { 113 113 $caps = array( 'spectate' ); 114 114 } … … 798 798 return (bool) apply_filters( 'bbp_show_user_profile', $retval, $user_id ); 799 799 } 800 801 /** Moderators ****************************************************************/ 802 803 /** 804 * Add a moderator to an object 805 * 806 * @since 2.6.0 bbPRess 807 * 808 * @param int $object_id Traditionally a forum ID, but could be useful 809 * @param int $user_id 810 * 811 * @return @mixed 812 */ 813 function bbp_add_moderator( $object_id = 0, $user_id = 0 ) { 814 return add_post_meta( $object_id, '_bbp_moderator_id', $user_id ); 815 } 816 817 /** 818 * Remove a moderator user ID from an object 819 * 820 * @since 2.6.0 bbPress 821 * 822 * @param int $object_id 823 * @param int $user_id 824 * 825 * @return mixed 826 */ 827 function bbp_remove_moderator( $object_id = 0, $user_id = 0 ) { 828 return delete_post_meta( $object_id, '_bbp_moderator_id', $user_id ); 829 } 830 831 /** 832 * Get user IDs of moderators for an object 833 * 834 * @since 2.6.0 bbPress 835 * 836 * @param int $object_id 837 * 838 * @return mixed 839 */ 840 function bbp_get_moderator_ids( $object_id = 0 ) { 841 return get_post_meta( $object_id, '_bbp_moderator_id', false ); 842 } 843 844 /** 845 * Get moderators for a specific object ID. Will return global moderators when 846 * object ID is empty. 847 * 848 * @since 2.6.0 bbPress 849 * 850 * @param int $object_id 851 * 852 * @return array 853 */ 854 function bbp_get_moderators( $object_id = 0 ) { 855 856 // Get global moderators 857 if ( empty( $object_id ) ) { 858 $users = get_users( array( 859 'role__in' => bbp_get_moderator_role(), 860 ) ); 861 862 // Get object moderators 863 } else { 864 $users = get_users( array( 865 'include' => bbp_get_moderator_ids( $object_id ), 866 ) ); 867 } 868 869 return apply_filters( 'bbp_get_moderators', $users, $object_id ); 870 }
Note: See TracChangeset
for help on using the changeset viewer.