WordPress.org

Support

Support » Themes and Templates » How to create one menu that changes dynamically in the PHP file

How to create one menu that changes dynamically in the PHP file

  • I have a membership site and would like to create a menu that will change for each member, specifically what content they have access to.

    For example, on the menu there are 5 or so tabs that will remain the same for all users, but there is a “My Subscriptions” tab that I would like to have show the content that the member has access to.

    My current solution is to create 20 different menus and 20 different if statements in the bottom-menu.php file of the theme. This isn’t efficient at all and with an increase in content, the number of menus I will have to create will increase tenfold.

    So instead I would like to have one menu that just changes in the PHP file, but I’m not sure how to do this. I can provide more information on request. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Andrew Nevins

    @anevins

    Forum moderator

    A slightly better solution would be to use a switch statement, as opposed to 20 if statements, but you’re left with the same logic.

    Yeah, I would like to have the menu check for a condition and then add an item to the menu if the condition is true. How exactly would I add an item to the menu from the PHP file?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to create one menu that changes dynamically in the PHP file’ is closed to new replies.