Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: New Groupblog Plugin

@boonebgorges

Keymaster

Mariusooms – great plugin! Really fills a need for my community.

I wanted the “Blog” link on the group options bar to go to the regular blog theme, so I wrote a few small functions to redirect the ‘blog’ slug to the subdomain address. Written in about five minutes, but it seems to work fine for me:

remove_action( 'wp', 'custom_bp_groupblog_setup_nav', 2 );
remove_action( 'admin_menu', 'custom_bp_groupblog_setup_nav', 2 );

function custom_bp_groupblog_setup_nav() {
global $bp, $current_blog;

if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item ) {

$bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $is_member ) ? true : false;

$group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';

if ( bp_groupblog_is_blog_enabled( $bp->groups->current_group->id ) )
bp_core_new_subnav_item(
array(
'name' => __( 'Blog', 'groupblog' ),
'slug' => 'blog',
'parent_url' => $group_link,
'parent_slug' => $bp->groups->slug,
'screen_function' => 'custom_groupblog_screen_blog',
'position' => 32,
'item_css_id' => 'group-blog'
)
);
}
}
add_action( 'wp', 'custom_bp_groupblog_setup_nav', 2 );
add_action( 'admin_menu', 'custom_bp_groupblog_setup_nav', 2 );

function custom_groupblog_screen_blog() {
global $bp, $wp;

$blog_details = get_blog_details( get_groupblog_blog_id(), true );

if ( $bp->current_component == $bp->groups->slug && 'blog' == $bp->current_action ) {
bp_core_redirect( $blog_details->siteurl );
}
}

Skip to toolbar