Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Solved ?] Exclude users/admins (based on their username) from seeing cached pages #7

Open
trendymail opened this issue Nov 26, 2022 · 6 comments

Comments

@trendymail
Copy link

trendymail commented Nov 26, 2022

Hello!

Found a "solution" (your milage may vary) to exclude users/admins (based on their username) from seeing cached pages.

Long story short: when a user/admin is logged in, WordPress send/receive a cookie containing its username.

=> wordpress_logged_in_[hash]

So, it was quite simple to exclude theses users/admins from seeing cached pages.

I don't know (yet) how to send a Pull Request so the "raw" code is attached below (advanced-cache.php).

Any advice/hint would be greatly appreciated; :)

And, again, many thanks for this plugin!

advanced-cache.php.txt

@sanderdekroon
Copy link
Owner

sanderdekroon commented Nov 26, 2022

I think your solution may work, but does require maintaining a list of administrators. I'd rater see we generate a list of administrators and export those to a file instead of manually maintaining a file. I think we can work that in later.

However, I did see some hardcoded paths regarding your development setup and the plugin header sees to be missing. Would you be willing to fix those issues and create an actual Pull Request? That way we can start integrating your solution so others may benefit from it :)

Documentation on how to create a Pull Request can be found on the Github docs.

In short: fork this repository, commit your changes to your fork and then create a pull request from the Github interface.

@trendymail
Copy link
Author

trendymail commented Nov 26, 2022

Hello!

[...] does require maintaining a list of administrators [...]

Indeed but I need to exclude admins and some users.

If you only want to exclude administrators, please use wp-cli.

Simple way get them:

php wp-cli user list | grep administrator | tr "\t" " " | cut -d " " -f 2 | sort > admin_list.txt

Many thanks for you anwser: I will create a Pull Request when I am sure everthing runs smoothly.

If it succeed, then plugin No Cache for Admins will no longer be needed (assuming all admins are excluded).

Have a great night. :)

@CyrilDesch
Copy link

Hello!

Found a "solution" (your milage may vary) to exclude users/admins (based on their username) from seeing cached pages.

Long story short: when a user/admin is logged in, WordPress send/receive a cookie containing its username.

=> wordpress_logged_in_[hash]

So, it was quite simple to exclude theses users/admins from seeing cached pages.

I don't know (yet) how to send a Pull Request so the "raw" code is attached below (advanced-cache.php).

Any advice/hint would be greatly appreciated; :)

And, again, many thanks for this plugin!

advanced-cache.php.txt

Work for me 👍 Thanks for the solution my friends

@trendymail
Copy link
Author

You (@sanderdekroon): I don't have the time right now to implement such a feature. If you want, you are free to submit a PR.

Me (@trendymail): I don't have the time to tell you how I managed to put this feature in production. If you want, just ask.

Cheers!

@meirkalmus
Copy link

any soltution for this?
i would like to prevent admins from being served by cache...

@sanderdekroon
Copy link
Owner

Unfortunately, no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants