Users module

As of ImpressPages CMS 1.0.5 version it has integrated users management module. You can find it in administartion area under Community -> User tab. This module allows website visitors to register and log in to the website.

Preparation

First of all, you need to create a new zone with associated group "community" and associated module "user".


Log in into administration area. Go to Developer -> Zones, press "new record" and fill in required information:

  • name - name of zone. Choose anything you like.
  • key - name of zone for use in PHP code. Typically the same name without special characters and with underscores instead of spaces. We will use the value "user" as an example.
  • template - choose one of existing page layouts of current theme.
  • associated group - use "community"
  • module - use "user".

Generate login box

<?php            
global $site;       
echo $site->getZone('user')->generateLogin(); //replace 'user' to your zone name           
?>

Get link to login page

<?php          
global $site;       
echo $site->getZone('user')->getLinkLogin(); //replace 'user' to your zone name          
?>

Generate link to registration page

<?php          
global $site;       
echo $site->getZone('user')->getLinkRegistration(); //replace 'user' to your zone name          
?>

Get logout link

<?php       
global $site;       
echo $site->getZone('user')->getLinkLogout(); //replace 'user' to your zone name       
?>

Get link to profile (available only if user is logged in)

<?php         
global $site;        
echo $site->getZone('user')->getLinkProfile(); //replace 'user' to your zone name          
?>

Check if user is logged in

<?php        
global $session;        
$session->loggedIn(); //return true if use is logged in.        
?>

Get logged in user id

<?php     
global $session;     
$session->userId(); //return integer user id     
?>

Get user data by id

<?php    
require_once(BASE_DIR.MODULE_DIR.'community/user/db.php');    
global $session;    
if($session->loggedIn()){    
  $id = $session->userId();    
  $userData = \Modules\community\user\Db::userById($id);    
  var_dump($userData);    
}    
?>

Manually login or logout user

<?php   
global $session;   
$session->login($userId); //login user with id $userId   
$session->logout(); //logout current user   
?>

Customization

You can change default template by overriding template.php file

 

You can add aditional fields to registration or profile pages by overriding config.php file.