public function settings_screen($group_id = null)
        {
            // $group_id = bp_get_group_id( $group_id );
            $is_enabled = ccgn_is_enabled($group_id);
            $tab_label = ccgn_get_tab_label($group_id);
            $slug = ccgn_get_slug($group_id);
            $level_to_post = ccgn_get_level_to_post($group_id);
            // Needed to use wp_terms_checklist()
            require_once ABSPATH . 'wp-admin/includes/template.php';
            ?>

				<p>
					Hub Narratives allows your hub to share stories and interact via comments with visitors to your hub space.
				</p>
				<p>
					<label for="ccgn_is_enabled"> <input type="checkbox" name="ccgn_is_enabled" id="ccgn_is_enabled" value="1" <?php 
            checked($is_enabled, true);
            ?>
 /> Enable hub narratives.</label>
				</p>

				<?php 
            // Only show the other settings once the plugin has been enabled for this group
            // This is necessary because the term for associating posts to this group is only created upon submit of the "enable" checkbox
            if ($is_enabled) {
                ?>
					<div id="ccgn_settings_details">

					<p>
							<label for='ccgn_tab_label'>Change the BuddyPress hub tab label from 'Narratives' to whatever you'd like.</label>
							<input type="text" name="ccgn_tab_label" id="ccgn_tab_label" value="<?php 
                echo esc_html($tab_label);
                ?>
" />
					 </p>
					 <?php 
                /* ?>
                		 <p>
                			<label for='ccgn_url_slug'>Change the slug to something other than 'narratives'.</label>
                			<input type="text" name="ccgn_url_slug" id="ccgn_url_slug" value="<?php echo esc_html( $slug ); ?>" />
                		 </p>
                		 <?php */
                ?>
					<p>
							<label for='ccgn_level_to_post'>Who should be able to create new posts?</label>
							<select name="ccgn_level_to_post" id="ccgn_level_to_post">
								<option <?php 
                selected($level_to_post, "admin");
                ?>
 value="admin">Hub Admins Only</option>
								<option <?php 
                selected($level_to_post, "mod");
                if (empty($level_to_post)) {
                    echo 'selected="selected"';
                }
                ?>
 value="mod">Hub Admins and Moderators</option>
								<option <?php 
                selected($level_to_post, "member");
                ?>
 value="member">Any Hub Member</option>
							</select>
					 </p>

					 <p>Select other groups that narratives published in this group could be syndicated to.</p>
					 <?php 
                // @TODO: Maybe only site admins should be able to add other groups
                // Handle group associations, which are a taxonomy
                // Get the syndicated groups selected for this group, add this group's term.
                $selected_terms = ccgn_add_this_group_term(ccgn_get_categories($group_id), ccgn_get_group_term_id($group_id));
                $tax_args = array('hide_empty' => false);
                $terms = get_terms('ccgn_related_groups', $tax_args);
                // TODO: This should be filtered by groups that don't have the plugin enabled.
                // get_terms either returns an array of terms or a WP_Error_Object if there's a problem
                if (!empty($terms) && !is_wp_error($terms)) {
                    $args = array('descendants_and_self' => 0, 'selected_cats' => $selected_terms, 'popular_cats' => false, 'walker' => null, 'taxonomy' => 'ccgn_related_groups', 'checked_ontop' => false);
                    wp_terms_checklist(0, $args);
                } else {
                    ?>
					<div class="error">
							<p>Looks like no group terms are set up yet. Check back later.</p>
					</div>
					<?php 
                }
                ?>
				</div> <!-- End #bcg_settings_details -->

			<?php 
            }
            // ends the "enabled" check
            ?>

				<div class="clear"></div>
				<script type="text/javascript">
					jQuery(document).ready(function() {
						//match visibility on page load
						if ( jQuery('#ccgn_is_enabled').is(':checked') ) {
									jQuery('#ccgn_settings_details').show();
							} else {
									jQuery('#ccgn_settings_details').hide();
							}
						//update visibility on change
						jQuery('#ccgn_is_enabled').click(function() {
							if ( jQuery(this).is(':checked') ) {
									jQuery('#ccgn_settings_details').show();
							} else {
									jQuery('#ccgn_settings_details').hide();
							}
						});
					});
				</script>

		<?php 
        }
/**
 * Can the current user create and edit a narrative post?
 *
 * @return boolean
 */
function ccgn_current_user_can_post($post_id = null)
{
    $user_id = bp_loggedin_user_id();
    // If specific to a post, base ability to edit on origin group, not the group where the post is displayed.
    // For general use, like checking to display "create new", use the current group id (post_id will be null).
    $group_id = $post_id ? ccgn_get_origin_group($post_id) : bp_get_current_group_id();
    $level_to_post = ccgn_get_level_to_post($group_id);
    $can_post = false;
    // Grant permission if the user is a site admin
    if ($user_id) {
        $can_post = current_user_can('activate_plugins');
    }
    // No need to check if the user is a site admin, or we don't know who the user is
    if ($user_id && !$can_post) {
        switch ($level_to_post) {
            case 'member':
                $can_post = groups_is_user_member($user_id, $group_id);
                break;
            case 'mod':
                $can_post = groups_is_user_admin($user_id, $group_id) || groups_is_user_mod($user_id, $group_id);
                break;
            case 'admin':
            default:
                $can_post = groups_is_user_admin($user_id, $group_id);
                break;
        }
    }
    return apply_filters('ccgn_current_user_can_post', $can_post, $group_id, $user_id);
}