Jump to content

Set a page to hidden for a specific Domain


MarcV
 Share

Recommended Posts

Hi, i want to set the Status of a page to hidden, so it won't be shown when a user comes from a specific hostname.

I added this in _func.php:

$page=$pages->get(1004);
$page->addStatus(Page::statusUnpublished);
$page->addStatus(Page::statusHidden);
 
But it still shows on the Website. What am I doing wrong?
Link to comment
Share on other sites

Hi @MarcV and welcome to the forums!

A few comments.

  • It's not a good idea to overwrite the $page variable because then the current page will refer to the page with ID#1004. Most of us use $p when referencing another page.
  • You are not saving the page, so the changes are not sticking, but then you probably don't want them to stick because then they would affect all users.
  • Can't you simply add a conditional at the top of template file for page#1004 that says to throw a 404 (throw new Wire404Exception();) if the page id is 1004 and the user's hostname is xxxxx?

Does that help?

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...