Answers.Body: <p>Register new user permissions to restrict access to those pages using the <a href="https://craftcms.com/docs/plugins/hooks-reference#registerUserPermissions" rel="nofollow"><code>registerUserPermissions</code></a> hook.
  Then use <a href="https://craftcms.com/docs/plugins/hooks-reference#registerCpRoutes" rel="nofollow"><code>registerCpRoutes</code></a> to setup routes to a controller action which checks for required user permissions before rendering the templates.</p>
  
  <p>Sorry if I’m missing something, but I don’t see how this has anything to do with the <code>hasCpSection</code> function.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-30T16:56:08.427Z
Answers.Text: 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.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-30T18:19:06.720Z
Answers.Text: 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).
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-30T08:39:50.183Z
Answers.LastActivityDate: 2016-09-30T08:52:26.207Z
Answers.LastEditDate: 2016-09-30T08:52:26.207Z
Answers.UserDisplayName: carlcs
Body: <p>I'm facing a problem which, on the surface, seems similar to <a href="https://craftcms.stackexchange.com/questions/11170/cannot-grant-user-group-plugin-permission-without-hascpsection">this thread...</a></p>
  
  <p>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 <a href="https://craftcms.com/docs/plugins/templates#giving-your-plugin-its-own-cp-section" rel="nofollow noreferrer"><code>hasCpSection</code></a> method. My plugin doesn't <em>need</em> a <code>hasCpSection</code> method, because there really isn't a "section" for people to access. Specifically, <strong>I don't need a link in the side nav, because my plugin doesn't have a main index page.</strong></p>
  
  <p>However, my plugin <em>does</em> have other pages. These other pages are only accessible via special links. Those special links appear on Entry edit pages, as a custom Fieldtype. <strong>These random pages are what I want my client to have access to.</strong></p>
  
  <p><a href="https://i.sstatic.net/55RWL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/55RWL.png" alt="&quot;Unauthorized&quot; message"></a></p>
  
  <p>And that's where I'm unable to use the solution provided in the related thread. Because when I link directly to a template, <strong>those pages are restricted by default.</strong> There's no way for me to "allow anonymous". I would have to give the user group full admin access (which is crazy), and <em>then</em> circle back and restrict permissions on the page.</p>
  
  <p>Any suggestions? This kinda feels like a bug to me, or perhaps a feature request.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-10T10:23:39.937Z
Comments.Text: 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.
Comments.UserDisplayName: Steve Holland
Tags: <plugin-development><users><control-panel><permissions>
Title: Allow a User Group to access plugin pages (without hasCpSection)
ThreadText: # Allow a User Group to access plugin pages (without hasCpSection)
  
  (Asked by: username_0 on 2016-09-30)
  
  I'm facing a problem which, on the surface, seems similar to [this thread...](https://craftcms.stackexchange.com/questions/11170/cannot-grant-user-group-plugin-permission-without-hascpsection)
  
  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`](https://craftcms.com/docs/plugins/templates#giving-your-plugin-its-own-cp-section) 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](https://i.sstatic.net/55RWL.png)](https://i.sstatic.net/55RWL.png)
  
  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.
  
  **Tags:** plugin-development, users, control-panel, permissions
  
  > **Comments:**
  > **username_1**: 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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2016-09-30. Score: 2
  
  Register new user permissions to restrict access to those pages using the [`registerUserPermissions`](https://craftcms.com/docs/plugins/hooks-reference#registerUserPermissions) hook.
  Then use [`registerCpRoutes`](https://craftcms.com/docs/plugins/hooks-reference#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.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_2**: 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).  
  
  ---
  
  