X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fuser%2Fsrc%2FPlugin%2FAction%2FAddRoleUser.php;fp=web%2Fcore%2Fmodules%2Fuser%2Fsrc%2FPlugin%2FAction%2FAddRoleUser.php;h=6980ff9b44ce69805b90449e79f3ff237f25475c;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/user/src/Plugin/Action/AddRoleUser.php b/web/core/modules/user/src/Plugin/Action/AddRoleUser.php new file mode 100644 index 000000000..6980ff9b4 --- /dev/null +++ b/web/core/modules/user/src/Plugin/Action/AddRoleUser.php @@ -0,0 +1,31 @@ +configuration['rid']; + // Skip adding the role to the user if they already have it. + if ($account !== FALSE && !$account->hasRole($rid)) { + // For efficiency manually save the original account before applying + // any changes. + $account->original = clone $account; + $account->addRole($rid); + $account->save(); + } + } + +}