This topic is locked
[SOLVED]

 Hide a menu item after login

7/19/2018 8:23:58 AM
PHPRunner General questions
gehrenfeld author

I am trying to hide a menu item once a user logs in. I want to hide the Register menu item.

I looked in the PHPRunner docs and I saw this code. But is crashes when I login.

if ($_SESSION["GroupID"]=="2")
{
$title = $menuItem->getTitle("Register");
if ($title=="Register")
return false;
}
return true;
admin 7/19/2018

When you say "it crashes", what exactly does it mean? If there is an error message you should post it here.

gehrenfeld author 7/19/2018



When you say "it crashes", what exactly does it mean? If there is an error message you should post it here.


Here is what I get.

Fatal error: Uncaught Error: Call to a member function getTitle() on null in C:\Bitnami\wampstack-7.1.17-0\apache2\htdocs\cookn\include\events.php:51 Stack trace: #0 C:\Bitnami\wampstack-7.1.17-0\apache2\htdocs\cookn\include\commonfunctions.php(1361): class_GlobalEvents->AfterSuccessfulLogin('garye', '', Array, Object(LoginPage)) #1 C:\Bitnami\wampstack-7.1.17-0\apache2\htdocs\cookn\classes\loginpage.php(711): SetAuthSessionData('garye', Array, false, '', Object(LoginPage), true) #2 C:\Bitnami\wampstack-7.1.17-0\apache2\htdocs\cookn\classes\loginpage.php(176): LoginPage->LogIn('garye', '') #3 C:\Bitnami\wampstack-7.1.17-0\apache2\htdocs\cookn\classes\loginpage.php(126): LoginPage->doLoginRoutine() #4 C:\Bitnami\wampstack-7.1.17-0\apache2\htdocs\cookn\login.php(128): LoginPage->process() #5 {main} thrown in C:\Bitnami\wampstack-7.1.17-0\apache2\htdocs\cookn\include\events.php on line 51
admin 7/19/2018

What event do you add this code to? Screenshot of the full PHPRunner window please with this code being open.

gehrenfeld author 7/19/2018



What event do you add this code to? Screenshot of the full PHPRunner window please with this code being open.


Login Page
https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=85444&image=1&table=forumreplies?dl=0

admin 7/19/2018

Wrong event. Please refer to the manual:

https://xlinesoft.com/phprunner/docs/menu_item_modify.htm

gehrenfeld author 7/19/2018



Wrong event. Please refer to the manual:

https://xlinesoft.com/phprunner/docs/menu_item_modify.htm



That worked. I spent a whole day looking on how to do that and never knew there was menu modify event.
Thank you for your help.