PHP code example of purplespider / silverstripe-discourse-sso
1. Go to this page and download the library: Download purplespider/silverstripe-discourse-sso 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/ */
purplespider / silverstripe-discourse-sso example snippets
namespace YOURNAMESPACE;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\FieldType\DBField;
class DiscourseSSOEndpointExtension extends DataExtension
{
public function updateExtraParameters(&$extraParameters, $member)
{
$extraParameters['add_groups'] = 'my-members';
$extraParameters['remove_groups'] = 'my-other-members';
$extraParameters['username'] = $member->ForumUsername;
$extraParameters['custom.user_field_1'] = "Scotland";
}
public function updateAuthentication(&$authenticated, $member, &$action)
{
if(!$member->EmailIsValidated) {
$authenticated = false;
$action = $this->owner->render(array(
'Title' => 'Please Verify Your Email Address',
'Content' => DBField::create_field(
'HTMLFragment',
"<p>Your email address has not yet been verified.</p>"
),
));
}
}
}