bernhard Posted February 5, 2021 Share Posted February 5, 2021 For advanced needs there is a module from @Robin S : https://processwire.com/talk/topic/21153-access-by-query-string/ But if you need something really quick and simple, just put that in your init.php: if($input->get('code', 'string') === 'YOURSECRET') { // remove the unpublished state in memory (non-persistant) $pages->get('/yourpage')->removeStatus('unpublished'); } This makes /yourpage accessible via /yourpage/?code=YOURSECRET ? PS: I had this need today to show a page to a user that has no login and to make sure that the page is also excluded from search results (that's why just hiding the page would not have been enough). 5 Link to comment Share on other sites More sharing options...
elabx Posted February 5, 2021 Share Posted February 5, 2021 Nice tip!! To elaborate on other examples, I do something like this to have this same "code to view" per page (in the sense of one code per page) like this on ready.php: if(!$user->isLoggedIn()){ wire()->addHookAfter('Page(template=sometemplate)::viewable', function($event){ $page = $event->object; $pass = wire('input')->get->text('pass'); if($page->page_pass && $pass){ if($page->isUnpublished() && $pass == $page->page_pass){ $event->return = true; } } }); } 5 Link to comment Share on other sites More sharing options...
bernhard Posted February 6, 2021 Author Share Posted February 6, 2021 (edited) What about this? ? if(!$user->isLoggedin() AND $page->template == 'sometemplate' AND $input->get('code', 'string') == $page->page_pass) { $page->removeStatus('unpublished'); } Edited February 6, 2021 by bernhard Didn't read it correctly on first response :) 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now