Skip to content

Instantly share code, notes, and snippets.

@r-a-y r-a-y/bp-groups-nav.php Secret
Created Jun 11, 2015

Embed
What would you like to do?
Get BP groups nav in the WP admin dashboard
<?php
function ray_admin_setup_globals() {
// ensure we're in the admin area
if ( ! defined( 'WP_NETWORK_ADMIN' ) ) {
return;
}
/* add checks here to ensure you're on your admin page before proceeding */
// grab a random group
$group = BP_Groups_Group::get_random( 1, 1 );
// fake that we're on a single group page
buddypress()->current_component = 'groups';
buddypress()->groups->current_group = groups_get_group( array(
'group_id' => $group['groups'][0]->id,
'populate_extras' => true,
) );
buddypress()->groups->current_group->is_user_member = true;
buddypress()->groups->current_group->user_has_access = true;
buddypress()->current_item = $group['groups'][0]->slug;
buddypress()->is_single_item = true;
}
add_action( 'bp_setup_globals', 'ray_admin_setup_globals', 11 );
function ray_admin_init() {
/* add checks here to ensure you're on your admin page before proceeding */
// needed to run group extension code in admin area
do_action( 'bp_actions' );
// grab the options nav
$group_nav = buddypress()->bp_options_nav[buddypress()->current_item];
// undo fake globals
buddypress()->current_component = '';
buddypress()->groups->current_group = 0;
buddypress()->current_item = '';
buddypress()->is_single_item = '';
}
add_action( 'admin_init', 'ray_admin_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.