Home › Forums › Community Forum › How to change Menu and Widgets when logged in
Tagged: advanced/php conditionals, menu
This topic contains 13 replies, has 4 voices. Last updated by Raam Dev 4 years, 2 months ago.
Topic Author | Topic |
---|---|
Posted: Tuesday Oct 16th, 2012 at 7:32 am #28506 | |
|
|
Hi I’ve managed to work your ‘advanced/php conditionals’: example #1′ to display different words on the page for people who are logged in. Jason’s video was really helpful. My site is http://www.sippclub.com I’d like to be able to offer a different menu at the top of the page when people are logged in. Please could you show me how I can do this. Thanks. Brian |
List Of Topic Replies
Author | Replies |
---|---|
Author | Replies |
Posted: Wednesday Oct 17th, 2012 at 6:57 am #28655 | |
|
|
Hi Brian. If the pages are protected with level restrictions, then you can configure your Alternative Views setting to hide protected content from Navigation Menus when the user doesn’t have access to them. [hilite path]Dashboard -› s2Member® -› Restriction Options -› Alternative View Protection[/hilite] Otherwise you’d need to find a way to use conditionals in your menus. You could try a text widget, or maybe another plugin that allows it. I hope that helps. :) |
|
Posted: Wednesday Oct 17th, 2012 at 7:35 am #28659 | |
|
|
Dear Cristián Thanks for your reply. I’d looked at the Alternative View Protection, but it seems to be the wrong way around for my purpose, in that it hides ‘protected’ content. At http://www.sippclub.com I want to show all four menu options for people who are not logged in. If they click a protected page (which I want to show to gain their interest), they will be directed to the ‘you have to be a member, join here’ page. Once they are logged in, I want to hide the first of the menu options saying ‘FREE membership’ because they are already a member and they’ve logged in. I don’t know how to ‘use conditionals in my menus’. I’m not sure how I can use a text widget in the main header navigation, but if you can show me how to do this, I’m sure that would work (I’ve already used ‘advanced/php conditionals’: example #1′ in sidebar widgets and they work perfectly). If you’re aware of a plugin that allows this to happen, please could you let me know. I look forward to hearing from you. Thanks. Brian |
|
Posted: Wednesday Oct 17th, 2012 at 4:58 pm #28749 | |
![]() |
|
Hi Brian, If you want to add s2Member conditionals to your WordPress theme’s menus, then you will need to edit your WordPress theme and make the customizations there. The code will be specific to your theme, but menu code is usually found in the header.php template file. Your theme may be configured to auto-generate the menu, in which case you’ll need to view the source code for the page with the generated menu and then manually rebuild the menu in the theme file, along with a few s2Member PHP conditionals, so that you can control the menus you want to hide and show. If you’re not comfortable with modifying WordPress theme files or with PHP itself, then we recommend posting a job on jobs.wordpress.net. Otherwise, you may want to ask WordPress-specific questions about theme files on either wordpress.stackexchange.com or the WordPress.org Support Forums. There is, unfortunately, no way for us to give specific advice for this type of modification because it is so specific to each WordPress theme. |
|
Posted: Thursday Oct 18th, 2012 at 4:04 am #28807 | |
|
|
Dear Raam Thanks for the detail. Sadly, I’m not a programmer, so I wouldn’t feel confident modifying the theme files. I’d be worried too that any theme updates would overwrite the changes, putting me back to square one. As a thought, I’ve created two menus in WordPress. One for logged in and one for logged out. Is there a way conditionals can be used to present the correct menu (depending on whether a person is logged in or out), rather than just try to hide some of the links in one menu? Brian |
|
Posted: Thursday Oct 18th, 2012 at 6:04 pm #28920 | |
![]() |
|
You should be able to do that with the WordPress wp_nav_menu() function (docs here). The conditional to check if the user is logged in or out is also a WordPress function: is_user_logged_in() (see docs here). However, you’ll need to consult with the WordPress Support forums for help with putting these functions together. |
|
Posted: Thursday Oct 18th, 2012 at 6:43 pm #28939 | |
![]() |
|
Actually, I just now answered his post: Which should have what you need. :) |
|
Posted: Friday Oct 19th, 2012 at 8:56 am #28995 | |
|
|
Dear Raam and Eduan Thanks for your help. I shall have a play and let you know how I get on. Brian |
|
Posted: Friday Nov 2nd, 2012 at 11:11 am #30474 | |
|
|
Dear Raam and Eduan Thanks for your help on this. It seems all the pointers you’ve indicated above should work, but I couldn’t make it work, nor could an IT mate of mine who builds websites. You’re right in that the change needs to be made in the header.php file, but despite his best efforts, he failed. He suspects it’s to do with the theme. We can create two menus in WordPress, but it only seems to make one of them work, and won’t allow switching between the two, whether you’re logged in or out. If you have any other things we could try, that would be good, but otherwise, don’t worry. Brian |
|
Posted: Friday Nov 2nd, 2012 at 5:53 pm #30501 | |
![]() |
|
Hi Brian, If it’s an issue with the theme, we recommend contacting the theme developer to see if they can fix it for you. Otherwise, you might try asking your question on wordpress.stackexchange.com or the WordPress.org Support Forums. |
|
Posted: Saturday Nov 3rd, 2012 at 11:30 am #30557 | |
|
|
Dear Raam Thanks for your reply. I have been in touch with the theme owner and they’re still considering a way to achieve it. If I can’t find a way to make this work, could there be another way to achieve this? Perhaps when a person logs in, they go to a completely different site – say members.sippclub.com (the main site is http://www.sippclub.com/). The disadvantage here is that there will be quite a lot of duplicate pages, which is not a great idea. Is this something that you’ve seen done, or that works? Brian |
|
Posted: Monday Nov 5th, 2012 at 5:09 pm #30686 | |
![]() |
|
Hi Brian, If you install WordPress on a different domain (even a subdomain like members.sippclub.com), the two installations of WordPress won’t be able to talk to each other, so if someone logs in on the main domain, they won’t be logged in or have any access to the protected content on the sub-domain. There’s no reason your theme developer shouldn’t be able to get your theme working, so I recommend going that route. |
|
Posted: Tuesday Nov 6th, 2012 at 11:46 am #30777 | |
|
|
Dear Raam Actually, the theme owner got involved and helped write some code using your conditionals and it’s now working absolutely perfectly. So thank you all for being so helpful once again. Brian |
|
Posted: Wednesday Nov 7th, 2012 at 5:42 pm #30939 | |
![]() |
|
Glad we could help, Brian! Thanks for the update and good to hear you got things working. :) |
This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.