Create a template override for the Profile view of Users. Go to Extensions - Templates - Templates - (for example) Protostar Details and files. Go to the tab Create Overrides and click com_users - profile from the column Components.
The override files are written into the folder templates/protostar/html/com_users/profile. Delete all the files except edit.php that needs to be customised. The following example has Author as the user group where members are allowed to change the password. Tested in Joomla 3.10.12.
Part 1 - insert the lines after the two lines loading the plugin language:Part 2 - find the lines from 'Iterate through the fields' and make the changes:
The override files are written into the folder templates/protostar/html/com_users/profile. Delete all the files except edit.php that needs to be customised. The following example has Author as the user group where members are allowed to change the password. Tested in Joomla 3.10.12.
Part 1 - insert the lines after the two lines loading the plugin language:
Code:
// Load user_profile plugin language$lang = JFactory::getLanguage();$lang->load('plg_user_profile', JPATH_ADMINISTRATOR);// mod allow only Author group to update password$author= 3;// user group id $user = JFactory::getUser();// current user$userId = $user->get('id');// user id$groups = JAccess::getGroupsByUser($userId); // user's user groups$allow = in_array($author, $groups);
Code:
<?php // Iterate through the fields in the set and display them. ?><?php foreach ($fields as $field) : ?><?php // If the field is hidden, just display the input. ?><?php // display password only to allowed group ?><?php if (($field->hidden) OR (($field->fieldname === 'password1' OR $field->fieldname === 'password2') AND !$allow)) : ?><?php // echo $field->input; ?><?php else : ?>
Statistics: Posted by toivo — Fri Apr 19, 2024 7:58 am