You are here

edit_own_user_account_permission.module in Edit own user account permission 7

Same filename and directory in other branches
  1. 7.2 edit_own_user_account_permission.module

File

edit_own_user_account_permission.module
View source
<?php

/**
 * Implements hook_permission().
 */
function edit_own_user_account_permission_permission() {
  return array(
    'edit own user account' => array(
      'title' => t('Edit own user account'),
      'description' => t('This module add \'edit own user account\' permission.'),
    ),
  );
}

/**
 * Implements hook_form_alter().
 */
function edit_own_user_account_permission_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  if ($form_id == 'user_profile_form' && $user->uid == arg(1) && !user_access('edit own user account')) {
    $form['account']['name']['#access'] = 0;
    $form['account']['mail']['#access'] = 0;
    $form['account']['current_pass']['#access'] = 0;
    $form['account']['pass']['#access'] = 0;
  }
}