public function register($data, Form $form)
    {
        $member = $this->addMember($form);
        if (!$member) {
            return $this->redirectBack();
        }

        // If they can login, immediately log them in
        if ($member->canLogin()) {
            Injector::inst()->get(IdentityStore::class)->logIn($member);
        }

        if ($this->RegistrationRedirect) {
            if ($this->PostRegistrationTargetID) {
                $this->redirect($this->PostRegistrationTarget()->Link());
                return;
            }

            $session = $this->getRequest()->getSession();
            $sessionTarget = $session->get('MemberProfile.REDIRECT');
            if ($sessionTarget) {
                $session->clear('MemberProfile.REDIRECT');
                if (Director::is_site_url($sessionTarget)) {
                    return $this->redirect($sessionTarget);
                }
            }
        }

        return $this->redirect($this->Link('afterregistration'));
    }