What filter or action hook to use in order to load some code before the template begins printing in BuddyPress? [closed]

Untested, but I’d start with something like this:

add_action( 'wp', 'your_function', 3 );
function your_function(){
    if ( is_page_template( 'some-template.php' ) ) { 
        if( some condition ) 
            locate_template( array( 'some-other-template.php' ), true );
        else
            return;
    }
    else 
        return;
}