EDIT: I received a direct, easy answer from the folks over on the BuddyPress forums:
There is a template tag called bp_current_component() that returns a boolean. So, in short, to tell if we’re currently in a BuddyPress-ized section of the site, we simply call:
if( bp_current_component() ){
…or, if we want to detect when we’re NOT in a BuddyPress area, the inverse:
if( !bp_current_component() ){
Easy peasy.
So, in total, the code looks like this:
if( !bp_current_component() ){
if ( is_page() ) {
if( empty( $wp_query->post->post_parent ) ) {
$parent = $wp_query->post->ID;
} else {
$parent = $wp_query->post->post_parent;
}
if( wp_list_pages( "title_li=&child_of=$parent&echo=0" ) ) {
echo '<ul id="subnav">';
wp_list_pages( "title_li=&child_of=$parent&echo=1" );
echo '</ul>';
}
}
} else {
echo '<ul id="subnav">';
if ( is_user_logged_in() ){
bp_get_loggedin_user_nav();
} else {
bp_get_displayed_user_nav();
}
echo '</ul>';
}