I'm facing a problem which, on the surface, seems similar to this thread...

Like that other thread, I've found that a specific user group is unable to access my plugin's pages because the plugin is lacking a hasCpSection method. My plugin doesn't need a hasCpSection method, because there really isn't a "section" for people to access. Specifically, I don't need a link in the side nav, because my plugin doesn't have a main index page.

However, my plugin does have other pages. These other pages are only accessible via special links. Those special links appear on Entry edit pages, as a custom Fieldtype. These random pages are what I want my client to have access to.

"Unauthorized" message

And that's where I'm unable to use the solution provided in the related thread. Because when I link directly to a template, those pages are restricted by default. There's no way for me to "allow anonymous". I would have to give the user group full admin access (which is crazy), and then circle back and restrict permissions on the page.

Any suggestions? This kinda feels like a bug to me, or perhaps a feature request.

  • Did the solution to this question solve your problem? I'm running into exactly the same issue. I was already using a Controller and I still get the Unauthorized message if I use the "login as" option on a non-admin user. Commented Oct 10, 2018 at 10:23

1 Answer 1


Register new user permissions to restrict access to those pages using the registerUserPermissions hook. Then use registerCpRoutes to setup routes to a controller action which checks for required user permissions before rendering the templates.

Sorry if I’m missing something, but I don’t see how this has anything to do with the hasCpSection function.

  • Interesting... You're suggesting a route which points to a controller action. Currently, my route points directly at the template. Which is where hasCpSection comes in... direct access to the template is unavailable unless I have a hasCpSection method.
    – Lindsey D
    Commented Sep 30, 2016 at 16:56
  • Interesting indeed. It would be nice if the registerCpRoutes hook was documented a bit better, this is not the first time it surprises me with unexpected behavior (hasCpSection effecting routes to templates but not to custom controller actions).
    – carlcs
    Commented Sep 30, 2016 at 18:19

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.