Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/15/2015 03:59:23 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Moderators: First pass at per-forum moderators.

This commit introduces a powerful feature commonly found in other popular forum software that has been on our wishlist for nearly 9 years. It includes the following changes:

  • Custom forum-mod taxonomy for assigning user nicenames to forum IDs
  • Associated functions for defining capabilities, labels, etc...
  • New capability filters for ensuring forum moderators have the ability to moderate forums even without the moderator role assignment
  • New option for toggling the entire feature on/off (on by default)

Props jmdodd, netweb. See #459.

File:
1 edited

Legend:

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

    r5770 r5834  
    5858 * @uses get_post() To get the post
    5959 * @uses get_post_type_object() To get the post type object
     60 * @uses bbp_get_public_status_id() To get the  public status id
     61 * @uses bbp_is_user_forum_mod() To check if the user is a forum moderator
     62 * @uses bbp_get_topic_forum_id() To get the opic forum id
    6063 * @uses apply_filters() Filter capability map results
     64 *
    6165 * @return array Actual capabilities for meta capability
    6266 */
     
    150154                // Unknown, so map to edit_others_posts
    151155                } else {
    152                     $caps[] = $post_type->cap->edit_others_posts;
     156
     157                    // If user is a per-forum moderator, make sure they can spectate.
     158                    if ( bbp_is_user_forum_mod( $user_id, bbp_get_topic_forum_id( $_post->ID ) ) ) {
     159                        $caps = array( 'spectate' );
     160
     161                    // Fallback to edit_others_posts.
     162                    } else {
     163                        $caps[] = $post_type->cap->edit_others_posts;
     164                    }
    153165                }
    154166            }
Note: See TracChangeset for help on using the changeset viewer.