Tagged: hide menu item, menu
-
AuthorPosts
-
March 1, 2014 at 7:01 pm #231117
I had a similar topic open here: https://kriesi.at/support/topic/entire-menu-disappearing-instead-of-select-items-with-membership-plugin/ but am opening this one because the topic and how I think I’ll need to tackle the issue has “morphed” into something a bit different.
I need to hide/show menu items based on the following logic (that comes from having another plugin, a membership plugin, installed):
if( !Dap_Session::isLoggedIn() ) {
//HIDE CERTAIN MENU ITEMS
}
else {
//SHOW CERTAIN MENU ITEMS
}I tried using the “Menu Visibility Control” plugin here: https://wordpress.org/plugins/menu-items-visibility-control/ which allows for using custom code/functions to hide/show menu items (for instance, on another site I run, I simply entered: !Dap_Session::isLoggedIn() within the “Visibility” option that appears for each menu item.
However, that plugin doesn’t seem to be compatible with the latest version of Enfold I’m running, as the “Visibility” option does not appear for each menu item.
I see that Enfold has it’s own available conditional menu logic available/built in, which I have activated after following the directions here: https://kriesi.at/support/topic/enfold-conditional-menu/
However, the conditional logic is limited to logged into/out of WP, along with user roles. I need to hide/show menu items based on whether they’re logged into/out of DAP (digitalaccesspass, a wordpress membership plugin).
The following code, when DAP is activated, returns whether a user is logged into/out of DAP:
Dap_Session::isLoggedIn()
Is there any way I can get the Enfold conditional menu logic to work with that check, instead of the WP logged in/out check?
- This topic was modified 10 years, 8 months ago by crazyflx.
March 1, 2014 at 7:21 pm #231119EDIT: What’s below doesn’t really solve my problem, I’m giving it as an example to possibly further assist with getting a “real” solution to the problem.
As a “hack” to get around this, I’m currently using the following code in my header.php file, just above the closing head tag:
<?php if(!Dap_Session::isLoggedIn() ) { ?> <style> #menu-item-1858 {display:none;} #menu-item-1728 {display:none;} #menu-item-1867 {display:none;} #menu-item-1849 {display:none;} </style> <?php } ?>
Where the given menu items need to be hidden (there are others, this is just an example) if the user is not logged into DAP. It’s working, but not when the menu is in “mobile” mode (my theme is set to be responsive).
Ideally, I need something to modify the Enfold conditional logic to allow for the “dap is logged in/out” condition and not just the “wp logged in/out” condition.
- This reply was modified 10 years, 8 months ago by crazyflx.
March 2, 2014 at 5:43 am #231202Hi!
Instead of hiding the menus via CSS, maybe this plugin will help: http://wordpress.org/plugins/zen-menu-logic/
It is like the widget logic plugin but for menu items.
You can refer to this link if you want to use the conditional for logged in users: http://codex.wordpress.org/Function_Reference/is_user_logged_in
Regards,
IsmaelMarch 3, 2014 at 8:54 am #231433Hello Ismael,
Thank you for your reply. The Zen menu logic unfortunately won’t help me. The wordpress “is user logged in” is close to what I need, but not quite.
Enfold already has the conditional menu logic, but I need an additional “if” condition. Instead of Enfold doing a
if ( is_user_logged_in() ) { ... }
and then hiding/showing menu items, I need it to do aif(!Dap_Session::isLoggedIn() ) {
and then hide/show certain menu items.I wouldn’t even mind replacing the existing Enfold condition of “if user is logged into wordpress” code with the “if user is logged into dap” code, since I’ll never need the “if is logged into wordpress” function.
In other words, I literally need Enfold to do a custom conditional menu logic check, and not one of the preexisting conditional menu logic checks, with that check being:
if(!Dap_Session::isLoggedIn() ) {
March 3, 2014 at 11:29 am #231480Hey!
See https://kriesi.at/support/topic/using-conditional-menus-with-custom-defined-user-roles/ – it shows you how to define new conditional checks.
Cheers!
Peter -
AuthorPosts
- You must be logged in to reply to this topic.