Jump to content
Sign in to follow this  
cornell2

Disabling but Displaying Secondary Menu items

Recommended Posts

cornell2

OK - I know this is an obscure question (and quite possibly something that can be accomplished by tweaking general WP settings) - but I figured I would throw out the challenge: I am already using the cool trick posted here, on how to hide menu selections from unlogged in users. But what I now want to do is have certain secondary menu selections (from the dropdown) to be displayed but disabled for unloggedin users (ie they can see, select, but not click). Any insights (or css?) Thanks!

Share this post


Link to post
Share on other sites
Simon
Tricky, but wordpress nav menu does actually have filters, you could create a filter that checks for a logged in user and removes/adds menu items before it is sent to the browser. Wordpress forums would be a good place to ask/search this has more than likely been asked before, hell there is probably even a plugin.

Share this post


Link to post
Share on other sites
cornell2
Yes, I am evaluating a few plugins (my fear is that they will interfere with platform pro, or my custom css). I understand the wordpress nav filters - already using them to hide or show menus for logged-in users, along with custom css. I wanted another level of granularity: A. for users not logged in - they don't see certain menus at all B. for users logged in (but not admin) - then can see these certain menus - but cannot click C. for admin - can see and click (and thus view the page) I already do "A" using wordpress menu/filter plus custom css. For B and C it seems I need to add to functions.php ... I'd rather not (for simplicity I like to have anything custom inside the custom css section). So I guess I am looking for a css solution, though a plugin would be just as good.

Share this post


Link to post
Share on other sites
Simon
is_user_logged_in() checks if a registered user is logged in or not. current_user_can('manage_options') only admins have this role.

Share this post


Link to post
Share on other sites
cornell2
well, yes, that is the "general concept" - but implementing this, practically, is the challenge. Thanks. (it reminds me of when someone asks a specific question here, and someone proudly says "use custom CSS") - sort of like a scientist asking for a formula, and someone says "use numbers"). The helpless asker is needing something just a liiiiitttle more specific. ; ) Thanks!

Share this post


Link to post
Share on other sites
catrina
I don't think there's a CSS tweak for disabling certain secondary menu dropdown selections for users who aren't logged in since CSS is more for styling and hiding elements. I know how to make a link unclickable (well, technically it is clickable, but the users stays on the same page), which is done this way: [code]LINK NAME[/code] ^^^ The # sign replaces the actual link so the user can click on the link, but it doesn't go anywhere. This is not with CSS, however, and it's going to require coding other than CSS to work properly.

Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
cornell2
I can restate this into two "tasks" 1. I want to have one set of menus for admin-level users, and another for non-admin users and those non logged on. 2. I want to have certain menu items be "clickable" (you know what I mean) - only for logged in users - but visible for all users. In some ways these are two very separate problems - a. VISIBILITY (or filtering) of menu items based on user-role/LEVEL b. Menu item "clickability" based on user-role/Level/Loggedin Status but really, the biggest problem is to detect the role of the current user in order to selectively display / activate items. This can be done using PHP current_user_can() - but I prefer to have this done completely inside the custom-css section. I have never tried to embed PHP inside this section, so I have no idea what is going to happen ... so I am going to start experimenting However, it would save a lot of time if there was someone here that had some experience of insight to offer. Thanks!

Share this post


Link to post
Share on other sites
catrina
It sounds like this type of issue is for the WordPress.org forums: http://wordpress.org/support. There are probably topics on this already if you search (or you can create a new topic).

Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
cornell2
I was able to partially achieve what I wanted, using custom css - the rest I have to code with PHP. But this leads me to a little issue of etiquette here. The forum interface is nagging me to accept or reject the answer. Really - my question was not answered, but for some reason "reject" feels a little rude to me. Accepting the answer would not be accurate since the my question was in no way answered (and would be misleading for those searching for a similar issue). What's the right protocol here?

Share this post


Link to post
Share on other sites
kastelic
I think if you "accept" and then and post another comment it will remain open for the moderators. At any rate, you can use a hook to inject CSS based on PHP conditions, for example, put something like this in functions.php: [code]add_action('wp_head','custom_css'); function custom_css(){ if is_user_logged_in(){ ?>

Share this post


Link to post
Share on other sites
cornell2
hmmm ... I am going to have to ponder this approach. Thanks. I wish I had seen it earlier (I coded a CSS approach - created a class which is referenced in the menu items 'optional css class') Thanks! PS - the problem with clicking "accept" when the question is not really answered is that it rather discourages others from contributing - and annoys those who later search for answers only to find a question marked as "answered" not really answered. If a question appears answered (accepted), someone who might actually have the solution might never look at the question, since it appears to be answered and closed. For instance - I wonder aloud if you would have looked at this discussion had I already accepted the 'answer'. I doubt it. And precisely because I had not accepted - you offered a very viable and useful solution. (thanks)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×