/** * Returns an array of capabilities based on the role that is being requested. * * @since 2.0.0 bbPress (r2994) * * @todo Map all of these and deprecate * * @param string $role Optional. Defaults to The role to load caps for * @uses apply_filters() Allow return value to be filtered * * @return array Capabilities for $role */ function bbp_get_caps_for_role($role = '') { // Which role are we looking for? switch ($role) { // Keymaster case bbp_get_keymaster_role(): $caps = array('keep_gate' => true, 'spectate' => true, 'participate' => true, 'moderate' => true, 'throttle' => true, 'view_trash' => true, 'assign_moderators' => true, 'publish_forums' => true, 'edit_forums' => true, 'edit_others_forums' => true, 'delete_forums' => true, 'delete_others_forums' => true, 'read_private_forums' => true, 'read_hidden_forums' => true, 'publish_topics' => true, 'edit_topics' => true, 'edit_others_topics' => true, 'delete_topics' => true, 'delete_others_topics' => true, 'read_private_topics' => true, 'publish_replies' => true, 'edit_replies' => true, 'edit_others_replies' => true, 'delete_replies' => true, 'delete_others_replies' => true, 'read_private_replies' => true, 'manage_topic_tags' => true, 'edit_topic_tags' => true, 'delete_topic_tags' => true, 'assign_topic_tags' => true); break; // Moderator // Moderator case bbp_get_moderator_role(): $caps = array('spectate' => true, 'participate' => true, 'moderate' => true, 'throttle' => true, 'view_trash' => true, 'assign_moderators' => true, 'publish_forums' => true, 'edit_forums' => true, 'read_private_forums' => true, 'read_hidden_forums' => true, 'publish_topics' => true, 'edit_topics' => true, 'edit_others_topics' => true, 'delete_topics' => true, 'delete_others_topics' => true, 'read_private_topics' => true, 'publish_replies' => true, 'edit_replies' => true, 'edit_others_replies' => true, 'delete_replies' => true, 'delete_others_replies' => true, 'read_private_replies' => true, 'manage_topic_tags' => true, 'edit_topic_tags' => true, 'delete_topic_tags' => true, 'assign_topic_tags' => true); break; // Spectators can only read // Spectators can only read case bbp_get_spectator_role(): $caps = array('spectate' => true); break; // Explicitly blocked // Explicitly blocked case bbp_get_blocked_role(): $caps = array('spectate' => false, 'participate' => false, 'moderate' => false, 'throttle' => false, 'view_trash' => false, 'publish_forums' => false, 'edit_forums' => false, 'edit_others_forums' => false, 'delete_forums' => false, 'delete_others_forums' => false, 'read_private_forums' => false, 'read_hidden_forums' => false, 'publish_topics' => false, 'edit_topics' => false, 'edit_others_topics' => false, 'delete_topics' => false, 'delete_others_topics' => false, 'read_private_topics' => false, 'publish_replies' => false, 'edit_replies' => false, 'edit_others_replies' => false, 'delete_replies' => false, 'delete_others_replies' => false, 'read_private_replies' => false, 'manage_topic_tags' => false, 'edit_topic_tags' => false, 'delete_topic_tags' => false, 'assign_topic_tags' => false); break; // Participant/Default // Participant/Default case bbp_get_participant_role(): default: $caps = array('spectate' => true, 'participate' => true, 'read_private_forums' => true, 'publish_topics' => true, 'edit_topics' => true, 'publish_replies' => true, 'edit_replies' => true, 'assign_topic_tags' => true); break; } return apply_filters('bbp_get_caps_for_role', $caps, $role); }
/** * Fetch a filtered list of forum roles that the current user is * allowed to have. * * Simple function who's main purpose is to allow filtering of the * list of forum roles so that plugins can remove inappropriate ones depending * on the situation or user making edits. * * Specifically because without filtering, anyone with the edit_users * capability can edit others to be administrators, even if they are * only editors or authors. This filter allows admins to delegate * user management. * * @since bbPress (r4284) * * @return array */ function bbp_get_dynamic_roles() { return (array) apply_filters('bbp_get_dynamic_roles', array(bbp_get_keymaster_role() => array('name' => __('Keymaster', 'bbpress'), 'capabilities' => bbp_get_caps_for_role(bbp_get_keymaster_role())), bbp_get_moderator_role() => array('name' => __('Moderator', 'bbpress'), 'capabilities' => bbp_get_caps_for_role(bbp_get_moderator_role())), bbp_get_participant_role() => array('name' => __('Participant', 'bbpress'), 'capabilities' => bbp_get_caps_for_role(bbp_get_participant_role())), bbp_get_spectator_role() => array('name' => __('Spectator', 'bbpress'), 'capabilities' => bbp_get_caps_for_role(bbp_get_spectator_role())), bbp_get_blocked_role() => array('name' => __('Blocked', 'bbpress'), 'capabilities' => bbp_get_caps_for_role(bbp_get_blocked_role())))); }
/** * Initialize forum-specific roles * * @since 2.6.0 */ public function roles_init() { // Get role IDs $keymaster = bbp_get_keymaster_role(); $moderator = bbp_get_moderator_role(); $participant = bbp_get_participant_role(); $spectator = bbp_get_spectator_role(); $blocked = bbp_get_blocked_role(); // Build the roles into one useful array $this->roles[$keymaster] = new WP_Role('Keymaster', bbp_get_caps_for_role($keymaster)); $this->roles[$moderator] = new WP_Role('Moderator', bbp_get_caps_for_role($moderator)); $this->roles[$participant] = new WP_Role('Participant', bbp_get_caps_for_role($participant)); $this->roles[$spectator] = new WP_Role('Spectator', bbp_get_caps_for_role($spectator)); $this->roles[$blocked] = new WP_Role('Blocked', bbp_get_caps_for_role($blocked)); }
function ntwb_bbpress_custom_role_names() { return array(bbp_get_keymaster_role() => array('name' => 'Captain', 'capabilities' => bbp_get_caps_for_role(bbp_get_keymaster_role())), bbp_get_moderator_role() => array('name' => 'Veteran', 'capabilities' => bbp_get_caps_for_role(bbp_get_moderator_role())), bbp_get_participant_role() => array('name' => 'Member', 'capabilities' => bbp_get_caps_for_role(bbp_get_participant_role())), bbp_get_spectator_role() => array('name' => 'Guest', 'capabilities' => bbp_get_caps_for_role(bbp_get_spectator_role())), bbp_get_blocked_role() => array('name' => 'Blocked', 'capabilities' => bbp_get_caps_for_role(bbp_get_blocked_role()))); }