diff --git a/config/default/views.view.user_admin_people.yml b/config/default/views.view.user_admin_people.yml index 58f3c8ead1..d122f711a4 100644 --- a/config/default/views.view.user_admin_people.yml +++ b/config/default/views.view.user_admin_people.yml @@ -71,6 +71,11 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true + action_title: Action + include_exclude: exclude + selected_actions: + - pathauto_update_alias_user + - user_cancel_user_action name: id: name table: users_field_data diff --git a/docroot/profiles/humsci/su_humsci_profile/su_humsci_profile.profile b/docroot/profiles/humsci/su_humsci_profile/su_humsci_profile.profile index 463ea5aea2..6b31542059 100644 --- a/docroot/profiles/humsci/su_humsci_profile/su_humsci_profile.profile +++ b/docroot/profiles/humsci/su_humsci_profile/su_humsci_profile.profile @@ -912,3 +912,16 @@ function su_humsci_profile_ckeditor5_plugin_info_alter(array &$plugin_definition $plugin_definitions['ckeditor5_table'] = new CKEditor5PluginDefinition($tableDefinition); } } + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function su_humsci_profile_form_user_form_alter(&$form, FormStateInterface $form_state) { + // Get current user roles and determine if has the 'administrator' role. + $roles = \Drupal::currentUser()->getRoles(); + $is_admin = in_array('administrator', $roles); + // Remove unnecessary URL alias fields from the user edit form for all users. + $form['path']['#access'] = FALSE; + // Remove Delete account button for all roles expect 'administrator'. + $form['actions']['delete']['#access'] = $is_admin; +}