User management
Autor: Franco F.
Visited 1689,
Followers 2,
Udostępniony 0
Hi everybody. I'd like to understand ho to make ma wesite main menu to be responsive by the group that belong to the user actually logged.
I've followed the example in here, that can helping me into making the user menu as a dropdown list that can be enougth to me (and leave the normal pages of the site to be driven by the standard menu).
The only point with that is that i cannot recognize the user group of the user. I would not basic user to see menu of the advanced one.
Posted on the
Hello.There is currently no way to hide objects depending on the user group.You can allow access for certain groups of users to certain pages.
Franco, further to what Aleksej correctly stated, you could have a locked page to which only appropriate groups get access, and on that page add a menu object starting at a (hidden) level under which all the user pages have been placed. Until a user logged in to see that page the menu would not be visible.
Autor
So, what is exactly the group that is retrieved by that function (in x5engine.php)?
I've displayed into a page and i so is something coded.
public function getUserByUsername($username)
{
$imSettings = Configuration::getSettings(); // Search in the file
if (isset($imSettings['access']['users'][$username])) {
$user = $imSettings['access']['users'][$username];
return array(
"id" => $user['id'],
...
"validated" => true,
"groups" => $user['groups'],
"hash" => $this->_getUserHash($username, $user['password'])
);
}
// Search in the DB
if ($this->db) {
$res = $this->db->query("SELECT * FROM `" . $this->db_table . "` WHERE `email`='" . $this->db->escapeString($username) . "'");
if (is_array($res) && count($res) > 0) {
$user = $res[0];
return array(
"id" => $user['id'],
..
"validated" => $user['validated'],
"groups" => array($imSettings['access']['webregistrations_gid']),
"hash" => $this->_getUserHash($user['email'], $user['password'])
);
}
}
return null;
}
By checking x5engine.php i've found this function:
public function checkAccess($page)
Is there ANY way to get the id number of certain pages?
What if i set 3 hidden pages for the 3 type of level of user and by this function i can know if the actual user belong to any of those level, so i will know which level is the user?!
I just saw that page ID is compiled runtime, so i think it can dinamically change between download!
Autor
It works.
By using checkAccess($page) i can indirectly recognize the user level. Now it just miss how to recognize automatically the page id of a specific page.
Suddenly I am out of my depth.
Good luck playing with code.