/**
 * Is it single category view
 * 
 * @return boolean
 */
function bcg_is_category()
{
    $bp = buddypress();
    if (bcg_is_component() && !empty($bp->action_variables[1]) && $bp->action_variables[0] == bcg_get_taxonomy()) {
        return true;
    }
}
function bcg_fix_category_permalink($catlink, $category_id)
{
    if (!bcg_is_component() || !in_bcg_loop()) {
        return $catlink;
    }
    $permalink = trailingslashit(bcg_get_home_url());
    //$cat       =  get_category( $category_id );
    //think about the cat permalink, do we need it or not?
    return $permalink . bcg_get_taxonomy() . '/' . $category_id;
    //no need for category_name
}
 public function view_single()
 {
     $bp = buddypress();
     if (function_exists('bp_is_group') && !bp_is_group()) {
         return;
     }
     //do not catch the request for creating new post
     if (bp_is_action_variable('create', 0)) {
         return;
     }
     $current_group = groups_get_current_group();
     if (bcg_is_disabled($current_group->id)) {
         return;
     }
     //if the group is private/hidden and user is not member, return
     if (($current_group->status == 'private' || $current_group->status == 'hidden') && (!is_user_logged_in() || !groups_is_user_member(bp_loggedin_user_id(), $current_group->id))) {
         return;
         //avoid prioivacy troubles
     }
     if (bcg_is_component() && !empty($bp->action_variables[0])) {
         //should we check for the existence of the post?
         add_action('bp_template_content', array($this, 'get_single_post_contents'));
     }
 }
 /**
  * Unpublish a post
  */
 public function unpublish()
 {
     if (!bcg_is_component() || !bp_is_action_variable('unpublish', 0)) {
         return;
     }
     $id = bp_action_variable(1);
     if (!$id) {
         return;
     }
     if (bcg_user_can_unpublish(get_current_user_id(), $id)) {
         $post = get_post($id, ARRAY_A);
         $post['post_status'] = 'draft';
         wp_update_post($post);
         //unpublish
         bp_core_add_message(__('Post unpublished', 'blog-categories-for-groups'));
     }
     bp_core_redirect(bcg_get_home_url());
 }