BenM (@alysko)

Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)

  • BenM
    Participant

    @alysko

    I note that problem too. Thanks for the information.

    @casiepa
    , is your bbp Toolkit still useful?


    BenM
    Participant

    @alysko

    Hi Pascal 😉

    No plugins like that, and bbp-toolkit already installed!

    In reply to: bbP Members Only

    BenM
    Participant

    @alysko

    Great ! Thank you !


    BenM
    Participant

    @alysko

    In fact, I prefered to do iy myself. It’s not specific to bbpress and I’m very surprised that WP doesn’t have this feature natively.

    For the ones who nedd this, here is my simple code :

    function yournamespace_exclude_menu_items( $items, $menu, $args ) {
        // only hide items in front, not admin
        if ( !is_admin() ) {
        // Iterate over the items
        foreach ( $items as $key => $item ) {
          // hide menu items which leads to pages with 'private' status
          if ( !is_user_logged_in() && get_post_status($item->object_id) == 'private' ) unset( $items[$key] );
        }
        return $items;
      }
      else return $items;
    }
    
    add_filter( 'wp_get_nav_menu_items', 'yournamespace_exclude_menu_items', null, 3 );
Viewing 4 replies - 1 through 4 (of 4 total)