Path

ezpublish / documentation / ez publish / technical manual / 4.x / features / advanced redirection after...


Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

Advanced redirection after login

This part of the 4.x documentation is for eZ Publish 4.0, only reference section is common for all eZ Publish 4.x versions as well as eZ Publish 5.x "LegacyStack", please select the version you are using for the most up to date documentation!

In eZ Publish 3.8 you can configure where to redirect a user when he/she logs in to the system. To enable this possibility for users, do the following:

  1. Add an attribute of the "Text line" datatype to your user class. If you have several user classes and wish to enable advanced redirection for all of them then you should add this attribute to each of your user classes (make sure you enter the same attribute identifier for all of them).
  2. Specify the identifier of the newly added attribute in the "LoginRedirectionUriAttribute" setting located in the "[UserSettings]" section of the "settings/siteaccess/example/site.ini.append.php" configuration file (replace "example" with the actual name of your siteaccess) like this:

    LoginRedirectionUriAttribute[key]=attribute_id
    

    key

    There are two keys that can be used: "user" for user class(es) or "group" for user group class(es).

    attribute_id

    The identifier of the newly added attribute (not ID number of the attribute).

Now you can specify the redirection URI in the text line field when creating/editing a user.

This possibility can be also enabled for user groups in the same way as for users. This means that you should add an attribute of the "Text line" datatype to your user group class(es) and specify its identifier in the "LoginRedirectionUriAttribute" setting using "group" as a key.

Example 1

Let's say that user John must be redirected to the "News" folder after log-in. The following list reveals how this could be done:

  1. Access the "Setup" tab in the administration interface, click "Classes" on the left and select the "Users" class group. You should see the list of classes assigned to this group. Find your user class there and click the "Edit" button located in the same line of the list. You will be taken to the class edit interface. Select the "Text line" datatype from the drop-down list located in the bottom, click the "Add attribute" button and edit the newly added attribute as shown below. Click "OK" to save your changes.
    A fragment of the class edit interface.

    A fragment of the class edit interface.

  2. Specify the identifier of the newly added attribute in the "LoginRedirectionUriAttribute" setting located under the "[UserSettings]" section of an override for the "settings/site.ini" configuration file. To do this, you should add the following line:

    LoginRedirectionUriAttribute[user]=redirection_uri
    

    where "redirection_uri" is the attribute identifier.

  3. Access the "User accounts" tab in the administration interface, use the "Sub items" list to find the user John and click the "Edit" button located in the same line of the list. You will be taken to the user edit interface. Specify "/news" in the text field called "Redirection URI" (the name of the newly added class attribute) as shown below. Click the "Send for publishing" button to save your changes and the user "John" will be always redirected to the "News" folder after log-in.
    Setting the redirection URI for the user John

    Setting the redirection URI for the user John

Example 2

Let's say that you wish to redirect all users that belong to the "Guest accounts" group to the "News" folder after log-in. The following list reveals how this could be done:

  1. Edit your user group class and add an attribute of the "Text line" datatype as shown below:
    A fragment of the class edit interface.

    A fragment of the class edit interface.

  2. Add the following line into the "[UserSettings]" section of an override for the "settings/site.ini" configuration file:

    LoginRedirectionUriAttribute[group]=start_page
    

    where "start_page" is the attribute identifier.

  3. Edit the "Guest accounts" user group and specify "/news" in the text field called "Start page" (the name of the newly added class attribute) as shown below. Click the "Send for publishing" button to save your changes and all the users that belong to the "Guest accounts" group will be always redirected to the "News" folder after login.
    Setting the redirection URI for the "Guest accounts" user group

    Setting the redirection URI for the "Guest accounts" user group

Important notes

If a user is a member of several groups (a child of several "User group" nodes), the system will use the redirection URI that is specified for the "main" group (main parent node). The following screenshot shows the user view interface for the user John that belongs to both "Guest accounts" and "Editors" user groups. The "Locations" list located under user preview allows to view and manage locations for the user object that is currently being viewed. The main location is displayed in a bold type ("Users / Guest accounts / John Doe" in our example).

A fragment of the object view interface for the user with two locations.

A fragment of the object view interface for the user with two locations.

Please note that the advanced redirection feature will get disabled if the redirection URI is already specified (e.g. via the "LastAccessesURI" session variable. Let's say that you have specified "/news" as the redirection URI for user John (see Example 1). If John launches a browser and goes directly to for example "http://yoursite.com/media_files" then he will not be redirected to "http://yoursite.com/news".

Svitlana Shatokhina (25/05/2006 2:08 pm)

Ricardo Correia (17/04/2013 2:29 pm)

Svitlana Shatokhina, Geir Arne Waaler, Ricardo Correia


Comments

  • To use this even if session variable 'LastAccessesURI' is set:

    You can overcome this by setting the post parameter 'RedirectURI' to '/' in your user/login.tpl template, this will make the user/login code ignore the session variable but still validate it as empty further down the code when it decides on reading those pr user / user group urls, ref:

    // Determine if we already know redirection URI.
    $haveRedirectionURI = ( $redirectionURI != '' && $redirectionURI != '/' );