Path

7x / documentation / ez publish / technical manual / 3.10 / 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

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 login. 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.
    A fragment of the class edit interface.

    A fragment of the class edit interface.

    Click "OK" to save your changes.
  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.
    Setting the redirection URI for the user John

    Setting the redirection URI for the user John

    Click the "Send for publishing" button to save your changes and the user "John" will be always redirected to the "News" folder after login.

Example 2

Let's say that you wish to redirect all users that belong to the "Guest accounts" group to the "News" folder after login. 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.
    Setting the redirection URI for the "Guest accounts" user group

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

    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.

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)

Svitlana Shatokhina (09/06/2006 8:53 am)


Comments

  • Redirecction in a inner page

    As state in the last paragraph, when you try to use redirection after login in a inner page it does not work. I found a solution to this issue by making an overwrite to the user/login template modifing this line

    <input type="hidden" name="RedirectURI" value="{$User:redirect_uri|wash}" />

    by this one

    <input type="hidden" name="RedirectURI" value="/" />

    This make the advanced redirection functionality to work in any case. The bad thing about it, is when you try to login a user that does not have the redirection attribute, after login, it always will redirect this user to the home page of your site.
    • Re: Redirecction in a inner page

      Hi, sounds like a bug to me, can you please report to http://issues.ez.no ? Thank you!