Skip to:
Content
Pages
Categories
Search
Top
Bottom

Make member profile private based on member type.

  • @garprogram

    Participant

    Hello everyone, thanks in advance …..
    I have a buddypress with different members types, coaches and players.
    I’m trying to make private members profiles with type = coaches with this code:

    function member_profile_test(){
      $user_id = bp_displayed_user_id();
      $member_type = bp_get_member_type($user_id);
      if($member_type !== 'players' && !is_super_admin() && !bp_is_my_profile()){
       wp_redirect(home_url() . '/error');
      }
    } 
    add_action( 'bp_before_member_home_content', 'member_profile_test' );

    But at this point (‘bp_before_member_home_content’) it is too late, the site has already begun to write content and wp_redirect display an error in php.

    What is the right way to do this?

    Thank for your help…. Sorry for my english…

Viewing 1 replies (of 1 total)
  • @garprogram

    Participant

    This work….

    function member_profile_test(){
      if( !bp_is_user()){
        return;
      } 
      $user_id = bp_displayed_user_id();
      $member_type = bp_get_member_type($user_id);
      if($member_type !== 'coaches' && !is_super_admin() && !bp_is_my_profile())
       bp_core_redirect( 'Your choice' );
    } 
    add_action('bp_init','member_profile_test');
Viewing 1 replies (of 1 total)
  • The topic ‘Make member profile private based on member type.’ is closed to new replies.
Skip to toolbar