Home Forums Front-end Issues Menu conditional display based on an ACF field value


Menu conditional display based on an ACF field value

  • Hi there,

    Sorry if I missed the point in one of the other topics, but here is what I would like to do with no solution yet:

    I use some ACF fields attached to the user profil.
    One of them is a yes/no field defining the right for the current user to access a specific page via a menu.

    On the main menu, I would like to display the link to this page ONLY if the ACF field is set to yes.

    TBN: Users with this field set to “yes” or set to “no” have the same WP user role and this must stay this way, it’s why I’m looking for another solution…

    Thanks for your help!


  • You need to build a custom menu walker, there are tutorials like this one

    Sorry, but this is beyond my ability to help with here and all I can do is tell you what needs to be done.

    In the walker, when the menu item is shown you need to get the current logged in user id and check the field and show or now show the menu item. This will likely require added these checks to both the start_el() and end_el() functions of your custom walker.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.