Skip to content
Snippets Groups Projects
Commit 0547eb8b authored by Liam Morland's avatar Liam Morland
Browse files

ISTWCMS-5085: Hide links to menu edit and delete for non-admin

parent f5b3194b
No related branches found
No related tags found
1 merge request!153ISTWCMS-5085: Prevent non-admin access to menu add, edit, and delete
......@@ -9,6 +9,7 @@ use Drupal\Component\Utility\Html;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\media_library\MediaLibraryState;
......@@ -473,6 +474,13 @@ function uw_cfg_common_form_node_uw_ct_web_page_edit_form_alter(array &$form, Fo
* Menu edit form: admin/structure/menu/manage/{menu}.
*/
function uw_cfg_common_form_menu_edit_form_alter(array &$form, FormStateInterface $form_state, string $form_id): void {
// Hide links to menu edit and delete for non-admin.
if (!\Drupal::currentUser()->hasPermission('administer menu')) {
foreach (Element::children($form['links']['links']) as $element_key) {
$form['links']['links'][$element_key]['operations']['#access'] = FALSE;
}
}
// Prevent certain changes to the home page.
//
// No changes for those with access.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment