Documentation 1.x

Users core plugin

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 log in or log out user

<?php
global $session;
$session->login($userId); //log in user with id $userId
$session->logout(); //log out 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.

Example plugin

This plugin:

  • adds users approval function to the administration panel
  • informs about new registered users.
  • includes example how to hide content for non registered users

Comments (13)

Caps

Caps

Is the login script already built?

Mangirdas

Mangirdas

This is a login script. You can create user registration on your website using this. Earlier this was a plugin. Now it is embedded into core.

srdjan

srdjan

first step done, and I paste all this php part into main.php of template, but nothing happed?

Caps

Caps

Way to complicated for your average admin. Should there be a register.php script? If you change templates you must start over again?

Mangirdas

Mangirdas

We are working on ImpressPages 1.1 where a lot more functionallity will be done using drag and drop.

Rüdiger

Rüdiger

Im a new. OK. I could follow the preparation steps.
But I have no idea where to put the php code e.g. to get a login box.

Mangirdas

Mangirdas

If you use default theme, add login code to ip_themes/ip_default/main.php file. Specific place depends on your needs.

Rüdiger

Rüdiger

thanks. main.php was a good hint.
I really like impresspages. Its much easier to start with as Joomla.
For a Sport Portal I need to share pictures .. only with registered users.
A bit more elaborated login procedure would be nice.

Jacobo Lopez

Jacobo Lopez

hey i just tried to add the registration area, and i am gettin an error that says NOTICE Undefined variable: userId and some lines with the local server rout.( source)

Mars

Mars

When will the user core be ready in impresspages 2.x?
The cms is amazing, good work!!

Mangirdas

Mangirdas

Now we are working on forms. Several days left. Then users module. So you should expect it about 15 of march.

Mars

Mars

Thank you for answering that fast.
Do you have someting like a feature roadmap yet?
Would be cool to see what u are planing.

Mangirdas

Mangirdas

Sure. Here you can see comming releases: https://github.com/impresspages/ImpressPages-CMS/issues/milestones

Write a comment

You must be logged in to comment.