简体   繁体   中英

how to add current user id to menu link in joomla

I want to pass the user id as filter with menu link to select items from list of database object that belong to that user. How to add current user id to menu link. The xml file parmaters are static I think. They doesnt work.

You don't need to add the User ID to the menu link (and security wise it's probably a very bad idea). You can retrieve the User ID of the current user anywhere in Joomla!.

eg ( you haven't specified your Joomla! version but for 2.5 you can get it this way )

$user = JFactory::getUser();
$userId = $user->get('id');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM