Site icon Hip-Hop Website Design and Development

How do I method eradicating menu objects on the fly primarily based on settings in my plugin?

I’ve began writing a plugin that permits the administrator to pick particular pages and set them to be seen solely to logged-in customers; the plugin optionally applies the restriction to all baby pages too. When a website customer makes an attempt to view any of those pages, they get redirected to the login web page.

Thus far, so good. All of it works to that time, and duplicates performance I’ve seen in current plugins.

Nevertheless, what I additionally wish to do is to routinely take away all of these pages (together with baby pages, the place specified) from the front-end website’s menus. I do not need them seen in any respect until you are logged in.

I’ve seen options the place individuals create two menus and change between them relying on logged-in standing, however that is an additional step I would somewhat not have.

I assumed I may maybe method this by including a filter or motion hook for ‘wp_nav_menu_items’ within the plugin code, however I’ve had no success with that but.

Any ideas?

Thanks
Phil


Extra particulars (smaller chunk of the issue):

This is some code from my plugin that I am making an attempt to make use of to hook into the menu objects:

add_filter('wp_nav_menu_items','ppa_filter_visible_menus');

operate ppa_filter_visible_menus($nav) {
    die("filter menus");
}

The issue I’ve is that ppa_filter_visible_menus isn’t known as.