Clone wiki

FrontendUser / Documentation


FrontendUser is a Processwire CMS / CMF module and provides login, logout and register functionality to frontend users. Because of the flexibility of Processwire CMS/ CMF it's extendable by plugins based on PW hooks. So just base features implemented by the module to keep it's core small and universal.

FrontendUser module features

  • login with error handling and value sanitizing
  • Plugin: ProcessForgotPassword core module integration
  • Plugin: LoginPersist module integration

  • user registration with username and email address already in use check

  • email adress pre-register validation (email verification plugin included)

  • Extendable with additional fields and hooks

  • forms generated by PW form api

Basic usage

Module installation

Install the module as described at the Processwire documentation.

Prevent redirection loops

If you redirect to the current page it could cause a redirect loop! So redirect destination should be another page or state (guest / loggedin) should be handled inside the template!

if ($user->isGuest()) {
    // do login or just write a "You're logged out..." message 
else {
    // do logout


Basic frontend login with username and password.

A Remember me (LoginPersist module integration, form field persist) and Forgot password (ProcessForgotPassword core module, form field forgot) plugin is built-in.

// load module
$fu = $modules->get('FrontendUser');

// prepare login form (default parameters)

// Default parameter
//$fu->login(array('username', 'password'));

// Additional LoginPersist and ProcessForgotPassword module integration (built-in)
//$fu->login(array('username', 'password', 'persist', 'forgot'));

// process login / form submit

// output form
echo $fu->render();

Short form

// load module
$fu = $modules->get('FrontendUser');

// login
echo $fu->login(null, $redirectDestination);   // with default fields
//echo $fu->login(array('username', 'password', 'persist', 'forgot'), $redirectDestination);


Logout the current user.

// load module
$fu = $modules->get('FrontendUser');

// logout the current user


Basic user registration with username, email and password.

The additional form field emailValidation loads the email pre-registration validation plugin to verify the email address before the user is saved.

// load module
$fu = $modules->get('FrontendUser');

// prepare register form

// Default parameter
//$fu->register(array('username', 'email', 'password'));

// Additional email pre-register validation plugin (built-in)
//$fu->register(array('username', 'email', 'emailValidation', 'password'));

// process register / form submit

// output register form
echo $fu->render();

Short form

// load module
$fu = $modules->get('FrontendUser');

// registration
echo $fu->register(null, $redirectDestination);  // with default fields
//echo $fu->register(array('username', 'email', 'emailValidation', 'password'), $redirectDestination);

Styles, scripts & templates

The modules includes base styles, scripts and templates in the module directory You can overwrite these files with custom files inside the templates directory. If a custom style, script or template file exists it will replace the default file!

Login form


register form


Email validation template


Plugins / extensions

Extend the FrontendUser module with additional features by write a plugin based on Processwire hooks. See examples below.

Code snippets / examples