WordPress.org

Ready to get started?Download WordPress

Forums

Nav Menu Roles
[resolved] Detect if page is part of hidden menu (3 posts)

  1. batman42ca
    Member
    Posted 5 months ago #

    Is there a way, that I can programmatically check to see if a page is part of a menu that is only available to logged in users?

    My plan is as follows: If the member is not logged in, they can't even see the menu item. That's standard nav-menu-roles behaviour. But if they are logged in but not paid, I want them to see the menu item, but not see the content of the page.

    I know how to set up a hook in functions.php. All I need to know is what to check how to see if the page that is about to be displayed belongs to a menu that is configured to be hidden from logged out users. Where in the database is that menu configuration information stored and how can I read it and use it?

    https://wordpress.org/plugins/nav-menu-roles/

  2. helgatheviking
    Member
    Plugin Author

    Posted 5 months ago #

    NMR saves its information as post meta for each menu item, with the key "_nav_menu_role". Possible values being "in", for showing only to logged in users, "out" for showing to logged out users, or an array of allowed roles.

    I'm not sure how to connect a page to a menu item, menu items are their own post type.

    Good luck.

  3. batman42ca
    Member
    Posted 5 months ago #

    Thanks. That's exactly what I needed to know. The rest of what I need to know is a WordPress issue, rather than a plugin issue.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.