Jump to content
hakeryk2

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More