(This answer has been updated from the original which suggested hacking Joomla code, to this much better solution proposed in the comment below - thanks to @Irata!)
Joomla includes the custom fields by means of a plugin which is triggered on onContentPrepareForm. This solution involves writing a second plugin, also triggered on onContentPrepareForm, which removes the custom fields if the usergroup of the user being edited is within a predefined subset.
Here's the code of the plugin – put in remove_custom_fields.php, but set the usergroups of your system users appropriately (ensuring the case and spacing for the names of the usergroups is correct). (You could also change the code to set the usergroup names via plugin config.)
class plgUserRemove_Custom_Fields extends JPlugin { public function onContentPrepareForm(JForm $form, $data) { if (JFactory::getApplication()->isClient('administrator') && $form->getName() == "com_users.user" && $data->id > 0) // admin user edit form, and not creating a new user { $systemUsergroups = array("Super Users", "Manager"); // change to suit your system usergroups $user = JFactory::getUser($data->id); // get details of user being edited $usergrouphelper = JHelperUsergroups::getInstance(); $usergroups = $usergrouphelper->getAll(); // get all usergroups on the system via the helper class foreach ($usergroups as $usergroup) { // for each usergroup, check if the usergroup is in your systems usergroup, and if this user belongs to that usergroup if (in_array($usergroup->id, $user->groups) && in_array($usergroup->title, $systemUsergroups)) { $form->removeGroup('com_fields'); } } } } }
By way of explanation … The plugin checks that it's the administrator Edit User form that's being shown and that an existing user is being edited. It then checks if the user being edited has a usergroup which belongs to the $systemUsergroups array, and if so then the function removes the custom fields from the form.
Also, here's the plugin xml file I used - in a directory plg_user_remove_custom_fields.
<?xml version="1.0" encoding="utf-8"?> <extension version="3.8" type="plugin" group="user" method="upgrade"> <name>User - remove custom fields</name> <description>Plugin to remove custom fields of admin user edit</description> <files> <filename plugin="remove_custom_fields">remove_custom_fields.php</filename> </files> </extension>
Finally, make sure that this plugin is triggered after the System - Fields plugin, via the ordering on the admin plugins page.