Plans

Professional Subscription Control Panel with a Billing System and PayPal Payment.

Back to Plans Support

webmaster
webmaster

Hello,

Would you mind tell me how I can get user id and their roles within component/class/controllers?

dazmiller8556
dazmiller8556

You could use this https://octobercms.com/plugin/shahiemseymor-roles

and then something like this i think

  • Install the front-end user managment plugin.
  • Make a new role
  • Give the user a role
  • Use this code {% if hasRole('ROLE NAME HERE') %} Admin Power! {% endif %}

from here https://octobercms.com/plugin/shahiemseymor-roles/roles-not-working

Last updated

webmaster
webmaster

Thanks for your answer, but I know how using hasRole and can I want to know is it possible to do something like this in our class? and how it's possible.

ah, I found answer in your link.


use ShahiemSeymore\Roles\Models\UserGroup;
if (UserGroup::hasRole('my_cool_role')) {
     echo "I'm in!";
}else{
     echo "I suck!";
}

Last updated

1-3 of 3