Support » Plugins » Filter on nav_menu_item_id is not working

  • I’m using Members plugin created by Justin Tadlock.
    This plugin allows me to restric specific pages based on user role.

    This works fine. The only problem is that the pages are still shown in my menu.

    I’ve added the following code to the content-permission.php file in the Members plugin:

    add_filter( 'nav_menu_item_id', 'members_content_permissions_protect' );
        function members_page_permissions_protect($id) {
          /* Remove 'menu-item-' from 'menu-item-172' and only keep menu ID */
          $menu_id = preg_replace("/[^0-9]/", '', $id);
          /* Get page ID based on menu ID */
          $page_id = get_post_meta( $menu_id, '_menu_item_object_id', true );
          /* If the current user can view the page, return menu ID. */
          if ( members_can_current_user_view_post( $page_id ) )
            return $id;

    The function members_can_current_user_view_post works as it should (after a tiny tweek), but nothing is done to the menu. I’ve also tried returning ‘true/false’.

    Why isn’t this filter working?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Filter on nav_menu_item_id is not working’ is closed to new replies.