/** * Registers the plugin's default user roles. * * @since 1.0.0 * @access public * @global object $wpdb * @return void */ function mb_register_roles() { global $wpdb; /* Keymaster role args. */ $keymaster_args = array('labels' => array('plural_name' => __('Keymasters', 'message-board'), 'singular_name' => __('Keymaster', 'message-board')), 'capabilities' => mb_get_keymaster_role_caps(), 'description' => __('Keymasters are the administrators of the board. They have the permission to perform any forum-related tasks.', 'message-board')); /* Moderator role args. */ $moderator_args = array('labels' => array('plural_name' => __('Moderators', 'message-board'), 'singular_name' => __('Moderator', 'message-board')), 'capabilities' => mb_get_moderator_role_caps(), 'description' => __('Moderators are allowed to participate in the forums and moderate all topics and replies created by forum members.', 'message-board')); /* Participant role args. */ $participant_args = array('labels' => array('plural_name' => __('Participants', 'message-board'), 'singular_name' => __('Participant', 'message-board')), 'capabilities' => mb_get_participant_role_caps(), 'description' => __('Participants are allowed to participate in the forums by creating topics and replies.', 'message-board')); /* Spectator role args. */ $spectator_args = array('labels' => array('plural_name' => __('Spectators', 'message-board'), 'singular_name' => __('Spectator', 'message-board')), 'capabilities' => mb_get_spectator_role_caps(), 'description' => __('Spectators are allowed to read topics and replies but are not allowed to participate in the discussion.', 'message-board')); /* Banned role args. */ $banned_args = array('labels' => array('plural_name' => __('Banned', 'message-board'), 'singular_name' => __('Banned', 'message-board')), 'capabilities' => mb_get_banned_role_caps(), 'description' => __('Banned users are explicitly denied access to using the forums in any way.', 'message-board')); /* Register the roles. */ mb_register_role(mb_get_keymaster_role(), apply_filters('mb_keymaster_role_args', $keymaster_args)); mb_register_role(mb_get_moderator_role(), apply_filters('mb_moderator_role_args', $moderator_args)); mb_register_role(mb_get_participant_role(), apply_filters('mb_participant_role_args', $participant_args)); mb_register_role(mb_get_spectator_role(), apply_filters('mb_spectator_role_args', $spectator_args)); mb_register_role(mb_get_banned_role(), apply_filters('mb_banned_role_args', $banned_args)); /* Action hook for registering custom forum roles. */ do_action('mb_register_roles'); /* Filter the user roles option when WP decides to pull roles from the DB. */ add_filter("option_{$wpdb->prefix}user_roles", 'mb_option_user_roles_filter'); }
/** * Returns the ID/slug of the default forum role. By default, this is set to the `mb_participant` role. * * @since 1.0.0 * @access public * @return string */ function mb_get_default_role() { return apply_filters('mb_get_default_role', get_option('mb_default_forum_role', mb_get_participant_role())); }