In certain circumstances it would be nice to disable some accounts to change their own password (think group accounts).
I did not see any way of doing (I might be wrong) and thought it was a easy modification to this module to support and given the module name appropriate as well.

for your consideration
cheers

------------------------------------------------------------------------
<?php
// $Id: restrict_password_change.module,v 1.1 2008/11/06 02:32:53 jrglasgow Exp $
// by James Glasgow - Tribute Media - http://www.tributemedia.com

/**
* Implementation of hook_perm()
*/
function restrict_password_change_perm() {
return array('change other users password', 'change own password');
}

/**
* Implementation of hook_form_alter()
*/
function restrict_password_change_form_alter(&$form, $form_state, $form_id) {
global $user;
switch ($form_id) {
case 'user_profile_form':
//drupal_set_message('$form =

'. print_r($form, TRUE) .'

');
// check to see if the form is for the current user or if they have permission
if(($user->uid != $form['_account']['#value']->uid) && !user_access('change other users password')) {
// password cannot be changed
$form['account']['pass']['#access'] = FALSE;
// e-mail address cannot be changed
$form['account']['mail']['#access'] = FALSE;
// they cannot be deleted
$form['delete']['#access'] = FALSE;
} else if(($user->uid == $form['_account']['#value']->uid) && !user_access('change own password')) {
// password cannot be changed
$form['account']['pass']['#access'] = FALSE;
// they cannot be deleted
$form['delete']['#access'] = FALSE;
}
}
}

Comments

jrglasgow’s picture

Status: Active » Closed (duplicate)

Duplicate of #445718