Jump to content

madhu1

Members
  • Posts

    3
  • Joined

  • Last visited

madhu1's Achievements

Newbie

Newbie (2/6)

0

Reputation

  1. I get the Role Object that is selected on the current page from following code and then I access the id $page_role = $page->get("page_role"); I think it is correct..
  2. Thanks I thought I have posted my issue at the wrong location. Apologies for that. I must admit that the people reply to the queries quicker. Coming to the issue: I get the variable $template_ as follows $template_ = $templates->get('school_acvitity'); then I pass it to the function and $id is the ID of Role that should have permission setPermission($id, $template_); this Function have the above code. After applying the permissions when I check it in the Access tab of the template I get the checked boxes for create, new, edit. But when user login he doesn't get the option creating new page. Now, If i uncheck the permission for that role through admin it works. Its Strange.. the entire code is: $page_role = $page->get("page_role"); $id = $page_role->id; $template_ = $templates->get('school_acvitity'); setPermission($id, $template_); function setPermission($id,$template_){ $editRoles = $template_->get('editRoles'); $addRoles = $template_->get('addRoles'); $createRoles = $template_->get('createRoles'); $editRoles[] = $id; $addRoles[] = $id; $createRoles[] = $id; $template_->set('editRoles',$editRoles); $template_->set('addRoles',$addRoles); $template_->set('createRoles',$createRoles); $template_->save(); }
  3. I m very new to Processwire, I have worked in PHP but not much experience with Processwire. I have created a template 'school_acvitity'. Now, at runtime i create a new role 'school1' and assign that role edit, create and add permission by using Processwire API. It shows the fields(edit, create , new) marked in the template Access tab for the role school1. But when the user with the role school1 login it doesnt get the option for edit new. After this if I manually deselect the permission to create new pages through admin, the user gets the option to create new pages. the code is : $editRoles = $template_->get('editRoles'); $addRoles = $template_->get('addRoles'); $createRoles = $template_->get('createRoles'); $editRoles[] = $id; $addRoles[] = $id; $createRoles[] = $id; $template_->set('editRoles',$editRoles); $template_->set('addRoles',$addRoles); $template_->set('createRoles',$createRoles); $template_->save(); Appreciate any help for the above issue.
×
×
  • Create New...