Hide list items that are not "logged in user" in backend list view #808
-
Hi, I have a default admin view and i want to hide everything except the items that belong to the logged-in user. How can i achieve that? Have no clue what would be the best route to take. Kind regards, Tom |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Figured it out. I don't know if it's the best solution but it seems to work. I already had a component configuration field where i had to set the user group of the one i want to limit my users to. (if you don't need this you can just remove the checks and only do the line with the "$query->where..." ADD THIS CODE TO THE "Add PHP (getListQuery - JModelList)" field in the PHP TAB of your admin view.
|
Beta Was this translation helpful? Give feedback.
Figured it out. I don't know if it's the best solution but it seems to work.
The below code checks for a groupID being set in the component configuration. Then checks if logged in user is an admin. If user belongs to the group and if he is not an admin it adds the query to limit the list view to "show own items only".
I already had a component configuration field where i had to set the user group of the one i want to limit my users to. (if you don't need this you can just remove the checks and only do the line with the "$query->where..."
ADD THIS CODE TO THE "Add PHP (getListQuery - JModelList)" field in the PHP TAB of your admin view.
// get group ID from component parameter $groupID = J…