Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Hiding navigation links for BuddyPress pages for non-registered users

  • @nickharambee

    Participant

    Hi,

    I would like to be able to hide all of the tabs for the pages/sections of my BuddyPress installation, i.e. Activity, Forums, Groups, Members from non-registered (i.e. non logged-in) users. I have implemented the Private BuddyPress plugin, which protects the pages, but doesn’t hide the tabs.

    Could someone let me know how I hide the tabs too?

    Thanks,

    Nick

Viewing 4 replies - 1 through 4 (of 4 total)
  • @mercime

    Participant

    == but doesn’t hide the tabs. ==

    You mean hide the main navigation links to the BuddyPress pages?

    @nickharambee

    Participant

    Yes, that’s what I mean.

    Nick

    @mercime

    Participant

    @nickharambee Remove the BP Component Pages you want to make private from the custom menu https://codex.buddypress.org/extending-buddypress/how-to-set-up-your-main-site-navigation-using-the-built-in-wordpress-menus/

    Add the following to your theme’s or child theme’s functions.php file

    add_filter( 'wp_nav_menu_items', 'mme_loggedin_only_links' );
    function mme_loggedin_only_links($items) {
    if (!is_user_logged_in())
    return $items;
    else
    $ouractivity = '<li><a href="' . home_url('/') . 'activity' . '">' . __('Activity', 'buddypress' ) . '</a></li>';
    $ourmembers = '<li><a href="' . home_url('/') . 'members' . '">' . __('Members', 'buddypress' ) . '</a></li>';
    $ourgroups = '<li><a href="' . home_url('/') . 'groups' . '">' . __('Groups', 'buddypress' ) . '</a></li>';
    $ourgroupforums = '<li><a href="' . home_url('/') . 'forums' . '">' . __('Forums', 'buddypress' ) . '</a></li>';
    $items = $items . $ouractivity;
    $items = $items . $ourmembers;
    $items = $items  . $ourgroups;
    $items = $items . $ourgroupforums;
    return $items;
    }

    @nickharambee

    Participant

    Thanks very much. That works fine.

    Nick

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Hiding navigation links for BuddyPress pages for non-registered users’ is closed to new replies.
Skip to toolbar