mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
added removeFromGroupByCode() function to Member.php
I was using the addToGroupByCode() function today and it would have been handy to have a removeFromGroupByCode() so I decided to add one.
This commit is contained in:
parent
7cf8e65309
commit
9a11c643da
@ -876,6 +876,19 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a member from a group.
|
||||
*
|
||||
* @param string $groupcode
|
||||
*/
|
||||
public function removeFromGroupByCode($groupcode) {
|
||||
$group = DataObject::get_one('Group', "\"Code\" = '" . Convert::raw2sql($groupcode). "'");
|
||||
|
||||
if($group) {
|
||||
$this->Groups()->remove($group);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Array $columns Column names on the Member record to show in {@link getTitle()}.
|
||||
* @param String $sep Separator
|
||||
|
Loading…
Reference in New Issue
Block a user