How to control who can view certain pages in BuddyPress? [closed]

I am new to BuddyPress so I don’t know which functions and variables to use here.

Read the codex – for example:
http://codex.buddypress.org/developer-docs/the-bp-global/

You could create a function in your theme- functions.php or in bp-custom.php
and call it from template files
and pass it parameters like allowed_users, etc.

Or you code hard-code something like this into specific template files.

 global $bp; 
 $allowed_users_array = (1,4,5,7);
 if (in_array($bp->loggedin_user->id, $allowed_users_array)) { 
// Show page
} else { 
// "You are not allowed to view this page" message
// or load a custom error page using locate_template( array( 'some.php' ), true );
// or redirect somewhere by using bp_core_redirect( );
}