Programmatically remove guest permissions for file

Permalink
Hi all,

I'm running an event which should remove guest users' viewing permissions to the specified file ($f). The below code, when the event is run, is removing guest view permissions from files globally, not just for the file passed in.

$pk = PermissionKey::getByHandle('view_file');
$pk->setPermissionObject($f);
$pa = $pk->getPermissionAccessObject();
$pe = GroupPermissionAccessEntity::getOrCreate(UserGroup::getByID(GUEST_GROUP_ID));
$pa->removeListItem($pe);

Anyone with greater experience/knowledge of programming file permissions would be greatly appreciated - I feel like I've searched everywhere.

Many thanks!

cameronspixels
 
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
pe = GroupPermissionAccessEntity.... should read $pe = GroupPermissionAccessEntity....
cameronspixels replied on at Permalink Reply
cameronspixels
My mistake, thanks for pointing out. That's just my formatting in the post. It's $pe in the code I'm running.