This topic is locked

Adding a link to user profile to the menu

7/12/2013 5:32:49 PM
PHPRunner Tips and Tricks
Sergey Kornilov admin

Here is the situation - you want to give each user a quick access to her own data in users table. It would be nice to add 'My profile' link right to the main menu.
Link to user profile page looks like users_edit.php?editid1=XXXX. We assume that login table name is users and XXXX is the value of primary key field in users table.

  1. Save ID of user account in session variable. For this purpose add the following code to AfterSuccessfulLogin event

$_SESSION["user_id"]=$data["id"];


In this example id is a primary key column name in login table.
2. Create a new menu item via Menu Builder.

Link type: Application page

Link to: Users (login table) List page

Link text: My profile
3. Now add the following code to MenuItem: Modify event

if ($menuItem->getTitle()=="My profile") {

$menuItem->setUrl("users_edit.php?editid1=".$_SESSION["user_id"]);

}
return true;


This is it.

S
simonedan 7/19/2013



Here is the situation - you want to give each user a quick access to her own data in users table. It would be nice to add 'My profile' link right to the main menu.
Link to user profile page looks like users_edit.php?editid1=XXXX. We assume that login table name is users and XXXX is the value of primary key field in users table.

  1. Save ID of user account in session variable. For this purpose add the following code to AfterSuccessfulLogin event

$_SESSION["user_id"]=$data["id"];


In this example id is a primary key column name in login table.
2. Create a new menu item via Menu Builder.

Link type: Application page

Link to: Users (login table) List page

Link text: My profile
3. Now add the following code to MenuItem: Modify event

if ($menuItem->getTitle()=="My profile") {

$menuItem->setUrl("users_edit.php?editid1=".$_SESSION["user_id"]);

}
return true;


This is it.


Where exactly the Step 3. code should be inserted? Event, which exactly? Php Page which one exactly? Thanis

I
indigo 7/19/2013

I get an error --

Fatal error: Call to a member function gSQLWhere() on a non-object in ...output\include\users_variables.php on line 18
C
cms001 1/3/2014

Hi ,
I am getting this error.

Fatal error: Call to a member function getTitle() on a non-object in C:\Users\user\Documents\PHPRunnerProjects\cmsTimeSheet\output\include\appusers_events.php on line 27
Any idea how to fix this one?

Sergey Kornilov admin 1/3/2014

cms001,
make sure you add your code to correct event.