Skip to content

Instantly share code, notes, and snippets.

@sbrajesh
Created June 15, 2011 19:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sbrajesh/1027903 to your computer and use it in GitHub Desktop.
It will make the community activity sub tab as default activity tab on profile
//fix the nav default
function bpcom_fix_nav(){
global $bp;
if(!bp_is_my_profile())
return;
if ( $bp->current_component == BP_ACTIVITY_SLUG && $bp->current_action=="just-me" ) {
$action=bpcom_get_current_actual_action();
if($action==BP_ACTIVITY_SLUG||$action== bp_get_loggedin_user_username()){
//unset the default settings
remove_action( 'wp', 'bp_activity_screen_my_activity', 3 );
add_action( 'wp', 'bp_community_activity_screen', 3 );
$bp->current_action = BPCOM_ACTIVITY_SLUG;
}
}
}
add_action("init","bpcom_fix_nav");
function bpcom_get_current_actual_action(){
$request_uri=$_SERVER['REQUEST_URI'];
$uri_components= explode("/", $request_uri);
if(empty($uri_components))
return false;//just to prevent infinite loop
while(!($current_action= array_pop($uri_components)))
;
return $current_action;//first non empty string
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment