Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I make only one tab visible to users who are not logged in on Profiles?

  • @izzyian

    Participant

    How can I make ONLY one tab Visible (the groups tab, so others can still see publicly the groups that user is a part of) to users who are not logged in on a user profile? And when a user logs in then the whole navigation bar (#object-nav)becomes visible again for all user profiles?

    I see no plugins for this , so maybe there is some code I could add to my functions?

    Thank you for any help

Viewing 3 replies - 1 through 3 (of 3 total)
  • @izzyian

    Participant

    I think I may have found the navigation bar that has to do with users profiles location. Called home.php, in it I see some lines like :

    <?php do_action( 'bp_before_member_body' );
    
      elseif ( bp_is_user_friends() ) :
    	locate_template( array( 'members/single/friends.php'   ), true )
    
      elseif ( bp_is_user_forums() ) :
    	locate_template( array( 'members/single/forums.php'    ), true );
    

    So I see the tags “friends” and “forums”. I assume I have to make an If/else statement.

    1.) I guess an example code of what I need help with would be

    if ( is_user_logged_in() ) {
    
    // SHOW FRIENDS TAB AND FOURMS TAB
    
    <?php } else { ?>
    
    // SHOW NO FRIENDS TAB, SHOW NO FOURMS TAB
    			<?php } ?>
    

    2.) And Would I place the If/Else statement you help me with in the home.php file or my child theme functions file?

    @shanebp

    Moderator

    You’re looking at the templates that render the content for tabs.
    But you want to remove tabs.
    Because ‘groups’ may be the only tab available, you need to make ‘groups’ the default component.
    You may need to add or remove one or more add_filter calls depending on your installation.
    Try this in your bp-custom.php file:

    
    define( 'BP_DEFAULT_COMPONENT', 'groups' );
    
    function izzy_adjust_profile_nav() {
      if ( ! is_user_logged_in() ) {
    	add_filter('bp_get_displayed_user_nav_activity', 'izzy_profile_nav_remove', 10, 1 );
    	add_filter('bp_get_displayed_user_nav_friends', 'izzy_profile_nav_remove', 10, 1 );
    	add_filter('bp_get_displayed_user_nav_forums', 'izzy_profile_nav_remove', 10, 1 );	
    	add_filter('bp_get_displayed_user_nav_xprofile', 'izzy_profile_nav_remove', 10, 1 );	
      }
    }
    add_action( 'bp_init', 'izzy_adjust_profile_nav' );
    
    function izzy_profile_nav_remove($nav_array) { 
      $nav_array = '';
      return $nav_array;
    }

    @izzyian

    Participant

    Wow that worked thank you so much for your great help !

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I make only one tab visible to users who are not logged in on Profiles?’ is closed to new replies.
Skip to toolbar