Jump to content

If Admin Is Logged In Front Office Then


Recommended Posts

Hello community, 

 

Is there is any chance to get some code that will do something only for logged administrator in front office?

Something like:

 

if is_admin(1) { some code }

else { another code }

 

IE display "edit this" only for admins in product.tpl file?

Link to comment
Share on other sites

  • 2 weeks later...

I've recently done something like this, firstly you'll need to pass a variable to Smarty from whatever module you're playing with, for example:

 

$this->cookie = new Cookie('psAdmin');

if (isset($this->cookie->id_employee) &&  $this->cookie->id_employee != ''){

$employee = new Employee($this->cookie->id_employee);

if ( $employee->isSuperAdmin() ) {

$this->context->smarty->assign('issuperadmin', true);

}

}
Then you can use

{if $issuperadmin}<DO SOME STUFF>{/if}
in your template.

 

Credit goes to the "Ninja Customer" module for this, that's what I based the above code on.

  • Like 1
Link to comment
Share on other sites

  • 3 years later...
On 2/28/2016 at 7:52 PM, hakeryk2 said:

2 days ago when I found Ninja Customer module I tried to get the code from there to do what I want to do ... but You made it first :) I will try your code in next 2 days and I will let You know if it works or not. Thank You anyway.

has it worked? For which PS version this code fits? Thank you!

Link to comment
Share on other sites

On 2/25/2016 at 8:38 PM, ukvapeclub said:

I've recently done something like this, firstly you'll need to pass a variable to Smarty from whatever module you're playing with, for example:

 

 


$this->cookie = new Cookie('psAdmin');

if (isset($this->cookie->id_employee) &&  $this->cookie->id_employee != ''){

$employee = new Employee($this->cookie->id_employee);

if ( $employee->isSuperAdmin() ) {

$this->context->smarty->assign('issuperadmin', true);

}

}

Then you can use

 


{if $issuperadmin}<DO SOME STUFF>{/if}

in your template.

 

Credit goes to the "Ninja Customer" module for this, that's what I based the above code on.

where to put this code in PS 1.7? In smarty I can't do this... Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...