This topic is locked

Re-direct to page /table depending on Group

1/8/2009 5:17:08 AM
PHPRunner General questions
M
mmponline author

I need to get a specific page to open depending on the user's group. Eg.
If admin ( group = admin) logs in, it goes to menu. That's the standard.

If student logs in (group = student), it must go directly to a specific table's page. Eg. student_list.php
How do I accomplish this? Help appreciated.

J
Jane 1/8/2009

Stephan,
just check $_SESSION["Group"] variable in the AfterSuccessfulLogin event and redirect to the correct page.

hichem 1/8/2009

Stephan,

just check $_SESSION["Group"] variable in the AfterSuccessfulLogin event and redirect to the correct page.


Hi Jane, is it possible to show a different menu based on user profile and using the same mechanism you have described?

Can you provide an example please? Thanks

Hich

M
mmponline author 1/8/2009

Would also like to se an example code please.
The Group field will be Group and the specific group to be redirected say Students. Thus, if any other group ti should go a specific page, but if the group is Student, it must go to Eg. the student_list.php page.

J
Jane 1/9/2009

Hich,
to show or hide links on the menu page use Menu page: Before display event on the Eventstab.

Here is a sample:

if ($_SESSION["Group"]=="admin")

$xt->assign("TableName_tablelink", true);

else

$xt->assign("TableName_tablelink", false);


Stephan,
use AfterSuccessfulLogin event on the Events tab for this purpose. Check $_SESSION["Group"] variable and redirect to the correct page.

Here is a sample:

if ($_SESSION["Group"]=="Student")

{

header("Location: student_list.php");

exit();

}

M
mmponline author 1/9/2009

Jane
My GroupID in the permissions is setup to use the Registration Typefield as group field. The students in that field is set as: I am a Learner.
I thus used the following code:

//********** Redirect to another page ************

if ($_SESSION["Registration_Type"]=="I am a Learner")

{

header("Location: Student_Content_list.php");

exit();

}


This still goes to the menu page instead of the Student_Content_list.php page. What can be the problem? I tried underslashed between I-am_a_Learner with no luck.

J
Jane 1/9/2009

Stephan,
don't replace session variable with your own.

if ($_SESSION["GroupID"]=="I am a Learner")


Here is the list of all available PHPRunner session variables:

http://www.xlinesoft.com/phprunner/docs/ph...n_variables.htm

M
mmponline author 1/9/2009

Fantastic! Works fine. Much appreciated.
Last question on this:
If I am a Mentor needs to be directed to another page than the I am a learner, how would you combine the 2 codes in an events.

hichem 1/10/2009

Hich,

to show or hide links on the menu page use Menu page: Before display event on the Eventstab.

Here is a sample:
Stephan,
use AfterSuccessfulLogin event on the Events tab for this purpose. Check $_SESSION["Group"] variable and redirect to the correct page.

Here is a sample:


Thansk Jane,

I tried as you said and used:

if ($_SESSION["IsAdmin"])

$xt->assign("adminarea_link", true);

else

$xt->assign("adminarea_link", false);
But didnt work? Guests still see the menu admin area eventhough they cannto loginto it.

I wanted to hide the menu admin area (adminarea_link) from guest and non admin users.

How and where do I find out what the menu corresponds to (TableName_tablelink)?

IN my case I found adminarea_link in the menu.php.

Thanks for clarifying

J
Jane 1/12/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

M
mmponline author 1/12/2009

I've got it sorted out, Thanks Jane. This works fine:

//********** Redirect to another page ************

if ($_SESSION["GroupID"]=="I am a Learner")

{

header("Location: Student_Content_list.php");

}

if ($_SESSION["GroupID"]=="I am a Mentor")

{

header("Location: Acacemic_Content_list.php");

exit();

}
M
mmponline author 1/12/2009

Correction:

//********** Redirect to another page ************

if ($_SESSION["GroupID"]=="I am a Learner")

{

header("Location: Student_Content_search.php");

exit();

}

if ($_SESSION["GroupID"]=="I am a Mentor")

{

header("Location: Academic_Content_list.php");

exit();

}
S
steveh 2/6/2009

Just to correct this, the correct way to redirect in the AfterSuccessfullLogin event is as follows:-
global $defaulturl;

$defaulturl='WhateverPageIsNext.php';
Otherwise if somebody saves a link and clicks on it and is asked for a login it won't work, it'll just go to your redirect, not the page they saved in the link.
Steve