(c5.6) programmatically change the permission of a page
Permalink
Hi, I'm looking to programmatically change the permissions of a page whereas only the pageowner, admin (+ maybe an admin group) can see the page.
It is effectively to create a "publish page" feature where a user (pageowner) can create their content and then apply for publication, where admin can then revert the permission for all to see with the click of a button...
I don't want to have to go through the >EDIT>PERMISSIONS route. I just want the 'admin group' to be able to cast their eyes over the page, and then with the click of a form button, set the page permissions... something along:
If you can point me in the right direction, this would be splendid. thanks
It is effectively to create a "publish page" feature where a user (pageowner) can create their content and then apply for publication, where admin can then revert the permission for all to see with the click of a button...
I don't want to have to go through the >EDIT>PERMISSIONS route. I just want the 'admin group' to be able to cast their eyes over the page, and then with the click of a form button, set the page permissions... something along:
$u = new User(); /* GUEST (GUEST_GROUP_ID) PERMISSIONS */ $pkHandles = array('view_page'); $p->assignPermissions(Group::getByID(GUEST_GROUP_ID), $pkHandles);
If you can point me in the right direction, this would be splendid. thanks
Thanks for that. I have created a button to turn on and off those attributes and it works great!
Maybe in the future, I'll re-visit and look at viewing permissions, but this works great fro the time being
Thanks
Maybe in the future, I'll re-visit and look at viewing permissions, but this works great fro the time being
Thanks
You're very welcome. I like to brainstorm the easy ways of doing things because I'm not capable of the complicated ones lol
However, thinking about it, maybe you should look at the Composer feature as you're using 5.6 I don't use it but I believe that's what it is for (publishing content that Admin gets to check before going live). Have a look at that and possibly look at creation of your pages using Magic Data or Black Magic Data.
Another way to do it would be to create the page with an "Exclude from Navigation" attribute already set. This won't stop your person who is publishing from seeing the page, as long as they know the address of it. Then, Admin can just untick that attribute to make the page go live and everyone else will see it in the navigation.
A few ideas anyway, though I understand this isn't the precise answer you would like as I'm not a programmer. Just trying to help you avoid the 'changing permissions' ideas.
I'm certain that you could create a page owned by a specific user (by the user clicking a button maybe), in a specific location, with the 'exclude from nav' attribute set and allow them to edit it using JTFs addons mentioned above, I've done something very similar before and have little programming knowledge.
Good luck,
Mike