0

As the title says, I want to be able to display some information in the product page that only appears for admins logged in.

  • 1st question: How do I define an user (client) in frontend as admin?
  • 2nd question: How do I show that information (inside a div for example) only to the clients that I want, or in this case, are admins?

Is this possible?

4
  • It is not possible. FE and BE are separate codes and sessions.
    – Sanju
    Nov 8, 2019 at 13:25
  • @Sanju looking for another alternative, do you think I can show a product attribute only for one type of customer group? that way I define a customer group for my admins and then only them can read the info I need them to read Nov 8, 2019 at 14:05
  • Yes, that is possible. You can easily fetch a customer group in front.
    – Sanju
    Nov 8, 2019 at 14:20
  • @Sanju Ok, thank you! :) Nov 8, 2019 at 14:36

1 Answer 1

0

I made an helper that accordingly to the customerId on frontend, returns true or false if he's admin (all you gotta do is place the customerId that is an admin frontend's account).

public function isAdmin(){
        $customerId = $this->_customerSession->getId();

        if($customerId == 3){
            return true;
        } else return false;

        return false;
    }
2
  • Might want to be mindful of FPC too with this approach Jan 13, 2020 at 16:33
  • @Rhys-SproutDesk you're not wrong.. how do you think I should proceed instead of doing this? Jan 13, 2020 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.