Roles.php in User protect 8
File
src/Plugin/UserProtection/Roles.php
View source
<?php
namespace Drupal\userprotect\Plugin\UserProtection;
use Drupal\Core\Form\FormStateInterface;
class Roles extends UserProtectionBase {
public function applyAccountFormProtection(array &$form, FormStateInterface $form_state) {
$applied = FALSE;
if (isset($form['role_change']['widget'])) {
$form['role_change']['widget']['#disabled'] = TRUE;
$applied = TRUE;
}
if (isset($form['account']['roles'])) {
$form['account']['roles']['#disabled'] = TRUE;
$applied = TRUE;
}
return $applied;
}
}
Classes
Name |
Description |
Roles |
Protects user's roles. |