Question: Determine If Admin User In Sales Input Form

Determine If Admin User In Sales Input Form

I need to make a couple of tweaks in views/sales/form.php based on if the current user is in the admin group. I'm sure that's a simple line of code, but I can't figure it out. Can you tell m

SS

Scott Smith

Asked
I need to make a couple of tweaks in views/sales/form.php based on if the current user is in the admin group. I'm sure that's a simple line of code, but I can't figure it out. Can you tell me what would work, please?
  • SS

    Scott Smith

    Answered
    Okay, I found a solution.

    In (themes/default/views) add.php and edit.php, I added the following at the top:

    $is_admin = ($this->sim->in_group('admin'));

    Then, in form.php, I can simply check for $is_admin where needed.
  • MS

    Mian Saleem

    Answered
    I am glad that you have managed it. Thank you for updating

    _There is a variable available in all the views as `$Admin` that will be same as of your `$is_admin`_
  • SS

    Scott Smith

    Answered
    Good to know, about $Admin.

    On the other hand, I have added another group that has "almost admin" so I still need to code my own in a few places. Others, however, might appreciate $Admin.
  • MS

    Mian Saleem

    Answered
    Hello,

    You can add the lines in `__construct` method of `app/core/MY_Controller.php` same as for Admin.

    `$Admin` is available to all the file in `themes` folder.
    `$this->Admin` is available to all the file in `app` folder.

    Thank you
  • SS

    Scott Smith

    Answered
    It seems this isn't completely accurate.

    $Admin is not set in default/views/header.php
  • Login to Reply