devblack.exe
devblack.exe

Reputation: 584

Opencart modification only for admins

I'm trying to create an ocmod for the admin panel. Basically, I want to add 2 buttons in the dashboard sidebar but only visible for users with administrator permissions.

How can I achieve that?

Note the custom views and controllers are ready.

Upvotes: 1

Views: 154

Answers (2)

OSWorX
OSWorX

Reputation: 138

for users with administrator permissions

What do you mean with that? In the backend you can define for each user the permissions easily. So, no checks for any session variables are needed, simply define the correct permission.

btw: if you intent to use that in future versions of OpenCart, you should use an event instead OCMod (which should be always the preferred method).

Upvotes: 0

focus.style
focus.style

Reputation: 6750

If you want to change anything in client page via login in admin panel as admin - can use this solution

In any controller you need add following:

if (isset($this->session->data['user_id']) && $this->session->data['user_id']) {
    $data['admin'] = true;
}   else {
    $data['admin'] = false;
}

Than in same controller's twig:

{% if admin %}
buttons on client side if admin is logged in in panel on the same browser
{% endif %}

Upvotes: 1

Related Questions