Clone wiki

FrontendUser / Register extensions and plugins

Registration extensions and plugins

Add default role

Set a default role during user registration. You need to hook before save() to get the changes saved!

<?php
$fu->addHookBefore('save', function($event) {
    $user = wire('fu')->userObj;
    $user->addRole('superuser');
});

Additional Nickname

Because the username is sanitized as "username" all blank and special characters will be removed. Nickname could be a custom user template field to display the users name as given by the user during registration sanitized as text.

<?php
$fu->addHookBefore('save', function($event) {
    $form = wire('fu')->form;

    if(!count($form->getErrors())) {
        wire('fu')->userObj->nickname = $form->fhValue('username', 'text');
    }
});

Updated