Jump to content

set admin pagestatus to hidden when a specifc user role is logged in


Orkun
 Share

Recommended Posts

I want to set the pagestatus of a admin-page to hidden when a user is logged in which has the role "company". I did this in the admin.php but it doesn't work. What I am missing?

if(wire('user')->isSuperuser()){
   $pages->get(1265)->removeStatus(Page::statusHidden);
}
else{
   $pages->get(1265)->addStatus(Page::statusHidden);
}
Link to comment
Share on other sites

You are not saving the status you have just set. Assign your page 1265 to a variable, set a status to it and save. Hidden and similar flags are saved to the db (see the column status in the table pages in your PW db) so you need to save.

Edited by kongondo
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

×
×
  • Create New...