Created
February 10, 2020 13:14
-
-
Save DorsetDigital/640b62a1cadb6c64196a6ef3fa897ead to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyMemberPage extends \Page | |
{ | |
private static $table_name = 'MyMemberPage'; | |
private static $controller_name = MyMemberPageController::class; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use SilverStripe\Control\HTTPRequest; | |
use SilverStripe\Security\Security; | |
class MyMemberPageController extends \PageController | |
{ | |
// This is where you tell the controller what actions it can perform. Each would be in the URL (eg. /memberpage/delete) | |
private static $allowed_actions = [ | |
'save', | |
'delete', | |
'confirm' | |
]; | |
public function delete(HTTPRequest $request) | |
{ | |
$accountId = $request->getVar('account'); | |
$account = Accounts::get()->byID($accountId); | |
if ($account->AccountOwnerID === Security::getCurrentUser()->ID) { | |
//You can delete the account here | |
} | |
} | |
public function getAccounts() | |
{ | |
return Security::getCurrentUser()->Accounts(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment