Thank you for the fantastic GeneratePress WordPress theme. It’s clean, easy-to-work with, and has offered a great entry point into WordPress.
Being at that entry point… I’ve created a child theme for the site I’m working on at http://www.webeatthegame.com/ It’s a development site for a gaming… blog? So, I’m slowly building it as I come to terms with the wonders of WordPress actions, classes, hooks, filters, functions, and objects.
Our current problem : We’d like to customise the primary <nav> menu displayed on the page based on :
Whether a user’s logged in
A user’s WordPress role.
A menu has been created in the WordPress Dashboard > Appearance > Menus section for each scenario. i.e. ‘public_menu’ for users who are not logged in; ‘member_menu’ for members; and ‘admin_menu’ for site administrators.
The functions relating to a user being logged in, and WordPress user roles I’ve got a handle on. Where I’m failing is how to replace the primary <nav> menu in the functions.php file.
I imagine the code will need to look something like this based on my research thus far (this is a basic ‘logged in/not logged in example only for simplicity’s sake) :
The plugin does exactly what I’d like, save one thing – adding a ‘Logout’ button to the menu. I believe I can figure out the code to inject a list item into the Primary Menu in the functions.php file.