BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 5
    billy on #14282

    thanks for you guys spport! looking forward to your reply

  • Participant
    Level: Initiated
    Posts: 5
    billy on #14198

    problem solved on other posts here, thanks for you guys’ support!

  • Participant
    Level: Initiated
    Posts: 5
    billy on #14188

    hello,
    I’d like to ask if the code mentioned in #4476 still works, cause when i added it to bp-custom.php, new registered user still have empty member type

    
    function buddydev_set_member_type( $user_id ) {
    	
    	$member_type = 'tutor';//change with the unique slug of your member type
    	bp_set_member_type( $user_id, $member_type );
    	
    }
    add_action( 'bp_core_activated_user', 'buddydev_set_member_type', 0 );
    

    what I’ve done up till now: installed bp member types plugin, created member type ‘tutor’ and added following code in bp-custom.php to restrict certain member type from accessing certain pages

    
    // Blocks pages from different users and users who aren't logged in
    function bp_redirect_pages() {
    	$current_user = wp_get_current_user();
    	// Declares a variable containing the current user's member type
    	$member_type = bp_get_member_type( $current_user->ID );
    	$url = $_SERVER['REQUEST_URI'];
    	$explode_url = explode("/", $url);
    	// Redirects members who are 'associate-member' types from access urls containing 'full-members'
    	if ( 'tutor' === $member_type && (in_array("compose", $explode_url)||in_array("view", $explode_url))) { 
    		wp_redirect( home_url() . '/shop/' ); 
    	}
    }
    add_action( 'template_redirect', 'bp_redirect_pages' );
    

    which is worked.
    i added your code below it.

    many thanks!

    • This reply was modified 5 years, 12 months ago by billy.