Can I just change the value of the filename.php for each of them in one of the loops of that script to change the link to “#” in all the restricted ones?
Right, that’s what I was getting at. It looks like you might be able to change the two unset function, to str_replace
, and be done with it. For instance, change
unset($submenu[$menu_item[2]][$i]);
to
str_replace($restricted, "#", $submenu[$menu_item[2]][$i][2]);
and
unset($menu[key($menu)]);
to
str_replace($restricted, "#", $menu_item[2]);
As far as showing the menus to users without change their caps, you’ll have to manually add the menus back. The menus aren’t filterable, so you can’t change what menus are hidden based on which capability. You’ll have to add the missing menus based on contribution level, and what menus the users are missing. The ‘Pages’ menu is $menu[20]
, so what you might try, is redeclaring that menu at say, $menu[21]
, only for those users that are missing the menu. What I’m describing would look like this
$menu[21] = array( __('Pages'), 'edit_pages', 'edit-pages.php', '', 'menu-top', 'menu-pages', 'div' );
33 $submenu['edit-pages.php'][5] = array( __('Edit'), 'edit_pages', 'edit-pages.php' );
34 /* translators: add new page */
35 $submenu['edit-pages.php'][10] = array( _x('Add New', 'page'), 'edit_pages', 'page-new.php' );
That should get you started I think. I may also be totally wrong, and if I am, let me know. We’ll keep brainstorming, and I’ll actually try code before I post it. I really think you’ll be good though.