Archived topic
Different Site-Headers for Logged in and Logged out user AND different pages
13 replies · Started by Patrick on November 10, 2022
Hi Support,
I try to figure out what the best solution is to create multiple Site-Headers depending on Logged-in/Logged-out/User Roles/Pages.
In the past I created Block Elements and set Display rules, somehow this is not longer possible? My site-header just broke after updating some elements? I am only able to set 1 Block Element as Site-Header?
I need different headers for:
- All pages except WC cart page for logged in user roles: Administrator, Customer
- All pages except WC cart page for logged out user
- Alle pages except WC cart page for logged in user role: Vendor
- WC Cart page for logged in user roles: Customer
- WC Cart page for logged out user
I appreciate your help with this, because I can't find another topic that explains how to do this?
Thanks!
Patrick
Hi Patrick,
To clarify, in your Block Element, are you not seeing the option for logged-in and logged-out for users in the Display rules section? Example: https://share.getcloudapp.com/E0uZDGXR
Having two Block Element - Site Headers should still work.
What updates changed your Header? Can you provide the link to the site in question? You may use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information
You should be able to add display rules for user roles as well. Example: https://share.getcloudapp.com/12uzGpQA
Hi Fernando,
Thanks for your fast reply.
I do see all the options and have set it up (as it worked before). But since I added a Container element and a shortcode, it seems that only one Site-Header Block could be active at the same time.
For example:
I have 2 Block Elements with type: Site Header
Restriction:
1) Header 1
- Show on all pages
- Hide on page: WC Cart
- Show for logged out user only
2) Header 2
- Show on all pages
- Hide on page: WC Cart
- Show for logged in user with roles: Administrator, Customer only
If I edit Header 1 and push update button, the header is only working correctly for logged out user. For logged in user (Admin, Customer) both header blocks are shown but without css -> check here: https://ibb.co/5Y3BkD8
If I edit Header 2 and click update, the header is shown correctly for logged in user (Admin, Customer) but not logged out user (same "error" like when I updated Header 1).
I created a staging site for you to reproduce the issue. You find the details in the private information area.
Thanks,
Patrick
Hi Patrick,
I tried checking the existence of the Element when logged out, and upon my test, I was able to see it appear.
See: https://share.getcloudapp.com/Jru8dZE6
As shown, this specific Container Block is the Container Block from the Logged Out Block Element.
Can you clear the cache of your browser and retest? Check in the inspector if you'll see this Container as well.
Hi Fernando,
Yes, I do see both logged out elements (one for mobile one for desktop). Thats my problem, sorry if I did not clarify that before. I designed different headers for mobile and desktop and used the "hide on xy" function in the element section. But it's not working as you see. And the CSS is broken?
The exact same structure and settings do work for logged in user, because I saved logged in user element. If I save now the logged out user element, it will work for logged out user (show only desktop or mobile with correct CSS laoded) BUT then logged in user sees both headers (desktop & mobile) with broken CSS.
Thanks
Patrick
I see. I can't seem to login anymore. Can you check if the credentials still work?
Your user is still active, please make sure you set the Cookie in your browser to access our staging site.
Thanks
Yes, it's working. Sorry about that. Didn't notice the cookie wasn't stored.
I see. Yes, the CSS is broken when logged out for the Block Element. The CSS seems to be missing.
In GenerateBlocks > Settings, can you try "Regenerate CSS files"?
If that doesn't work, try #1 here to test if a plugin is causing this: https://docs.generatepress.com/article/debugging-tips/
Hi Fernando,
Sorry for my late reply, I thought I already send it :-O.
I have deactivated all Plugins -> still same problem.
I have regenerated CSS file -> still same problem.
BUT when I set CSS to "inline" instead of "external file" it works??
Any idea? Could you please investigate?
Thanks,
Patrick
I see. Glad you got that to work.
Sometimes, unstyled content created through GenerateBlocks can conflict with some servers/caching methods. Can you revert to "External File" setting, and then can you check with your Hosting Provider if they clear server cache? I checked and your server seems to be cached: https://share.getcloudapp.com/9ZuzGOEO
Reference: https://docs.generateblocks.com/article/unstyled-content/
I can clear the server cache myself, and I have done that - issue still exists. We have no CDN, so Server Cache is the only caching we do. I am just on to create a local dev environment from a snapshot and will deactivate caching there completely and test again.
Thanks
I see. Hope it goes well! You're welcome Patrick!
Hi Fernando,
Sorry for my late reply.
I could finally test it on my local dev and the issue still exists without any caching active.
Any ideas?
Thanks,
Patrick
I see.
Can you try setting both Headers to draft, then for testing purposes, create two new Headers with similar Display rules but this time only include a simple Block like a GB Headline Block? Make sure to make modifications in their colors and font so that there is CSS involved.
Let's see if the CSS will load there.