PHP code example of moosylvania / silverstripe-registrationguard

1. Go to this page and download the library: Download moosylvania/silverstripe-registrationguard library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

moosylvania / silverstripe-registrationguard example snippets


use Moosylvania\RegistrationGuard\Service\RegistrationGuard;

// in your Form's constructor, after the rest of your fields
$fields->merge(RegistrationGuard::guardFields('members'));

// in your action handler
public function doRegister($data, Form $form)
{
    $result = RegistrationGuard::create($this->getRequest())->check($data, 'members');

    if ($result->shouldStop()) {
        $result->applyTo($form);
        return $this->controller->redirectBack();
    }

    // ... create the member
}