I am trying to: Keep my menu items in the menu
It appears that the toolset Access removes menu items from the menu, even though that is not the expected result.
I've tested this, and it's 100%, when I enable Access, which is set for logged-in users only on a page, that page is removed from the menu items.
I find myself using other tools, plugins, workarounds, and fixes more and more lately. At some stage, one doesn't need Toolset anymore.
I am now using Ultimate Member Content Restriction to bypass these issues.
Hi,
Welcome to Toolset support. Let me see if I understood the issue correctly?
Toolset Access controls not only the visibility of content but also the visibility of menu items linked to that content. When a page is restricted to logged-in users, Toolset Access removes its corresponding menu item for users who are not logged in.
This behavior is by design, aiming to prevent unauthorized users from seeing links to content they cannot access. However, it can lead to confusion, especially if the expectation is for the menu structure to remain consistent regardless of user login status.
If that is the case and I understood it correctly, here are possible solutions:
Manual Menu Management:
Instead of relying on dynamic menus that automatically include all pages, you can create custom menus and manually add the desired pages. This approach gives you full control over which menu items are displayed, regardless of the user's login status.
Custom Code to Control Menu Visibility
You can use WordPress filters to programmatically control the visibility of menu items based on user roles or login status. For example, using the wp_nav_menu_items filter, you can add conditions to display or hide specific menu items.
Here's a basic example:
function custom_menu_items($items, $args) {
if (!is_user_logged_in()) {
// Remove or modify $items as needed
}
return $items;
}
add_filter('wp_nav_menu_items', 'custom_menu_items', 10, 2);
The third alternative would be to use a third party plugin which you already did.
Thanks.