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(); }