Archived topic
Restricting content using GeneratePress
5 replies · Started by Joe on February 4, 2021
Hi,
I have some custom content types/pages that are for logged in users only. Instead of adding another plugin, I was thinking of using GeneratePress to manage it using a hook in the head. Perhaps hiding 'page-content' with CSS would be a bit weak, but how about a redirect to the login page with the conditions: is logged out, and is page/CPT X or Y etc. The data isn't particularly sensitive - just as long as it keeps most people out.
Could this work?
Many thanks! Joe
Hi Joe,
I don't think hook elements can do that.
But you could try this php snippet solution from David:
https://generatepress.com/forums/topic/create-a-redirection-for-a-page/#post-1000097
This article is about how to add php snippet.
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know :)
Thank you Ying,
That's a better solution, because I'd previously triedan html redirect which still briefly shows the starting page.
I have asked over on that thread, but perhaps you know also: how could I adapt that php for multiple pages? Eg mysite.com/restricted-page/* or even for a content type?
Many thanks! Joe
Hi Joe,
i have replied your reply on that other topic.
Thanks David and Ying,
All resolved..with the PHP redirect as discussed by David.
https://generatepress.com/forums/topic/create-a-redirection-for-a-page/page/2/
Thanks! Joe
Glad to hear that