felic Posted April 23, 2015 Share Posted April 23, 2015 Hi, probably a stupid simply task but this is my debut dealing with user/roles/permissions stuff within the frontend. Scenario: I have some (frontend) users tied to applied user roles (with appropriate permissions). These users have limited access (by those user roles/permissions) to the frontend views (provided by a custom frontend login form). Now there is a simple message list with several message items. Every page for single items comprises a field with a checkbox group (build as pages, s. https://processwire.com/talk/topic/313-checkbox-group-for-field/) which enables to assign any combination of user roles to a single item. Setting values by hand within the frontend template works smart: // Notice: "wpi1" e.g is the name of one checkbox page // Find every page (checkbox) with given properties $res = $pages->find("parent=/tools/partners/, name=wpi1"); // or "name="wpi1|wpi2|..." // Notice: Spares other selectors for this example $items = $pages->find("partner_membership=$res"); // Iterate and show the list(items) foreach($items as $item) { ... } But of course i'd rather set these values from the properties of the logged in user. And this is where i stalled. if($user->isLoggedin()) { 1a. // collect user roles for this user? $current_user_roles = $user->roles; or 1.b // getting $user permissions directly? $current_user_permissions = $permissions->find("user=$user"); } Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 23, 2015 Share Posted April 23, 2015 Sorry for the unelaborated answer, but have a look here at the $user / $roles and $permission parts: http://cheatsheet.processwire.com/ Edit: Do activate advanced mode to see all methods/properties. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now