- This topic has 15 replies, 5 voices, and was last updated 4 years, 1 month ago by
David.
-
AuthorPosts
-
February 27, 2022 at 12:11 pm #2135713
dominique
Hi there,
I use GeneratePress Premium and I have two elements :
– the first with two buttons : Register, Login
hook : after_header_content
users : disconnected– the second with two buttons : Account, Deconnection
hook : after_header_content
users : connectedThe website is very slow, so I use the cache of WP-Optimize (my host suggests to use WP-Optimize).
The website is now fast but the page comes from the cache and elements don’t update. For exemple, the user is connected but the buttons displayed are : Register, Login as if the user is disconnected.
Have you a solution to solve this problem ?
Thanks
DominiqueFebruary 27, 2022 at 12:39 pm #2135743Ying
StaffCustomer SupportHi dominique,
I don’t think GP can control how cache plugin works.
Does this happen only when cache plugin is activated?
Let me know.
February 27, 2022 at 2:39 pm #2135834dominique
Hi Ying,
Thanks for your answer.
Yes, this happen only when cache plugin is activated. No problem when there is no cache instead it is slow, slow …
I think that it is not about cache plugin works.
I think that, after it gives the page from cache, il will be useful to execute the code for elements. This needs to intercept event which says « the page is ready » then to run the code for elements.Best regards
February 27, 2022 at 2:47 pm #2135840Ying
StaffCustomer SupportNot sure what the settings look like in WP optimizer, if there’re exclusion options, can you try follow the instruction here for Autoptimize?
Let me know if it works.
February 27, 2022 at 3:27 pm #2135851dominique
Yes, there are exclusions but for url.
It is not possible to use that because I put elements on all pages.I excluded the pages for logins or registers (pages after user clicks on login or register button).
It is also possible to exclude cookies or pages in which there are strings in http header user agent.
It is written :
If any of the above strings are in the User-Agent HTTP header, the requested page will not be cached.But it is always the page which is excluded and not a part of the page (ie the elements inside the page).
Thanks
February 27, 2022 at 5:03 pm #2135920Leo
StaffCustomer SupportHave you checked with the support team of the caching plugin and see if they can comment?
Maybe it’s just a setting that needs to be turned off.
February 28, 2022 at 1:19 am #2136234dominique
Hi Leo,
Yes I contacted the support team of the caching plugin but at time, I don’t have an answer.
Everybody is not so reactive that GeneratePress 😉I contacted GP because elements are specifics to GP.
I sent to GP an email with a file with screenshots.Thanks
February 28, 2022 at 4:58 am #2136423David
StaffCustomer SupportHi there,
as a safety valve for this kind of issue its possible to use some CSS to hide/show the elements.
Can i see a page where both of the elements are visible ?February 28, 2022 at 6:35 am #2136525dominique
Hi David,
I sent yesterday a mail at wordpress@generatepress.com with screenshots.
I don’t see a field in the forum to put an upload file.Some infos in private information.
Thanks
February 28, 2022 at 6:43 am #2136539David
StaffCustomer SupportLets try to resolve the main issue.
1. Add this CSS:
body:not(.logged-in) .connected, body.logged-in .disconnected { display: none !important; }2. Edit the Buttons Block, and in Advanced > Additional CSS Class(es) you add either:
connected– for the buttons you want visible when the user is logged in.
disconnected– for the buttons you want visible when the user is NOT logged in.February 28, 2022 at 9:12 am #2136845dominique
Hi David,
Results of tests :
If the user is not connected, it is good : each choose in the menu displays the buttons (in elements) : Register / Login.
Then I connect as admin.On the page where I was, the buttons become : Account / Logout (it is normal).
Then I go on Home and .. the buttons become : Register / Login (it is not normal) and if I click on Login, it says : you are already connected (it is normal).What I did :
1) inside Appearence / Customize > Additional CSS, I put your CSS.2) in each element, i put for each button and for the group of buttons, always in block (right side) in in Advanced > Additional CSS Class(es) either connected or disconnected as you wrote in 2)
The first time, I put that only for the group button (Buttons with s) then as it is not good, I put also for buttons (Button without s) but it is the same : not good.Don’t forget that buttons are in elements in which I put the Display rules : connected or disconnected for users.
Thanks
February 28, 2022 at 5:22 pm #2137217Elvin
StaffCustomer SupportHi Dominique,
Assuming you really have 2 Block elements with different display rules (one for logged in users, another for non-logged in), the CSS shouldn’t be needed because the elements shouldn’t even appear on the page as the blocks shouldn’t render.
The display rule for logged in users is basically a
is_user_logged_in()and for non-logged in, its!is_user_logged_in().The DOM objects
wouldwon’t* have to be CSS styled if they don’t appear.If the page’s UI doesn’t change regardless if a user is logged in or not, I think you’ll just have to find WP-Optimize’s settings if it has some sort of page-caching. If it’s not there, you may have to look for that on the server’s end.
March 1, 2022 at 3:43 am #2137635dominique
Hi Elvin,
It is not an assumption, it is the reality : I have 2 block elements with different display rules.
WP-Optimize hides an entire page or nothing. So, after it renders the cached page, we need to change the elements.
David’s idea to change with CSS seems to be a good idea. But there is a problem.Is there CSS change happens after WP-Optimize renders the page ? or before ?
Thanks
March 1, 2022 at 4:11 am #2137678David
StaffCustomer SupportIs there a CSS issue if you disable WP Optimize ?
One thing you may want to consider is to NOT use the Logged In or Logged Out display rules. Just use the CSS method to hide them. Then there should be no issue if WP Optimize is just caching pages and not messing up the CSS
March 1, 2022 at 4:00 pm #2138708dominique
Hi David,
I did as you suggested and I saw that when I was connected as admin (with a small line at the top to go to dashboard) then buttons are OK. It is the same if I am not connected. We can say that your CSS is OK (I removed Logged In and Logged Out display rules).
But I had always problems when I change the choose in menu.
And I finally found the solution.
It is a checkbox in parameters of WP-Optimise (ELVIN won).
I had checked the box : Serve cached pages to logged in users
It was said : Enable this option if you don’t have user-specific or restricted content on your site.I remove the tick and now everything is OK.
Even my other problem that I reported to David : the third button that sometimes was not good.Everything is good now.
Many thanks to all the team (Ying, Leo, Elvin and David). Wonderful team !!
-
AuthorPosts
- You must be logged in to reply to this topic.