Hello,
How can I make the pages in the pages plugin always "private" and remove the access dropdown list ?
What do I need to change in the code ?
Chris
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 0 likes
- ChrisFr@ChrisFr

ChrisFr - 0 likes
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 0 likes
- ChrisFr@ChrisFr

ChrisFr - 0 likes
You must log in to post replies.I assume you mean 'Write access' field in the form.
You need to create an event in your custom plugin:
elgg-plugin.php
MyPlugin\Pages\Views.php
<?php namespace MyPlugin\Pages; class Views { public static function onlyAccessPrivate(\Elgg\Event $event) { $input_params = $event->getParam('input_params'); $return_value = $event->getValue(); if (empty($input_params)) { return; } if (elgg_extract('entity_subtype', $input_params) !== 'page') { return; } if (elgg_extract('purpose', $input_params) !== 'write') { return; } unset($return_value[ACCESS_PUBLIC]); unset($return_value[3]); unset($return_value[ACCESS_LOGGED_IN]); return $return_value; } }You need to override \mod\pages\views\default\forms\pages\edit.php in your custom plugin
In \mod\my_plugin\views\default\forms\pages\edit.php edit this code:
switch ($name) { case 'access_id': case 'write_access_id':On this:
switch ($name) { case 'access_id':Thank you Nikolai.
It works well !
But the writing dropdown list remains visible and displays "private".
Is there a way to hide it?
(I clear the cache before each test I run.)
Forgot about saving...
Add a new event in your custom plugin:
elgg-plugin.php
Create a new file \mod\my_plugin\classes\MyPlugin\Pages\FieldsHandler.php
<?php namespace MyPlugin\Pages; class FieldsHandler { public function __invoke(\Elgg\Event $event): ?array { $result = $event->getValue(); foreach ($result as $k => $field) { if (elgg_extract('name', $field) === 'write_access_id') { unset($result[$k]); } } $result = array_values($result); return $result; } }Note: your custom plugin must be placed under 'Pages' plugin on the /admin/plugins page.
Absolutely perfect !
Thanks again.