Answers.Body: <p>OK so here is my solution :<br>
  1/ define a custom permission for user groups</p>
  
  <pre><code>public function registerUserPermissions()
  {
      return array(
          'updateTopNews' =&gt; array('label' =&gt; Craft::t('Update Top News')),
      );
  }
  </code></pre>
  
  <p>2/ simply add css to hide the field when user has not the permission in my plugin init function</p>
  
  <pre><code> public function init () {
      parent::init();
  
      $user = craft()-&gt;userSession-&gt;getUser();
      if ( craft()-&gt;request-&gt;isCpRequest() &amp;&amp; $user ) {
  
          if ( !$user-&gt;can('updateTopNews') ) {
              craft()-&gt;templates-&gt;includeCss('#fields-topNews-field { display: none; }');
          }
      }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-14T05:14:25.937Z
Answers.Text: You better don't tell them, they can give themselves the "permission" with the web inspector tools. ;)
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-14T11:59:00.527Z
Answers.Text: Yeah dont worry my user are not tech savy no prob on that ! :)
Answers.UserDisplayName: migmaker
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-13T23:25:29.113Z
Answers.LastActivityDate: 2015-08-13T23:25:29.113Z
Answers.UserDisplayName: migmaker
Body: <p>So I am trying to hide (or disable) a field in the "Edit Entry" view in the CP.  </p>
  
  <p>I know how to test a user group :<br>
  <code>{% if currentUser.isInGroup('groupHandle') %}</code>  </p>
  
  <p>But I cannot find a hook in Craft Doc to change the rendering of my field ?
  Perhaps with <code>getInputHtml()</code>? But I dont understand exactly how...</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-13T23:20:38.883Z
Comments.Text: This is quite close to a solution : http://craftcms.stackexchange.com/questions/7084/get-the-current-entry-element-in-the-cp-edit-entry-view
Comments.UserDisplayName: migmaker
Tags: <plugin-development><control-panel><entries-field><permissions>
Title: Hide (or disable) an entry field in CP depending on user group permission?
ThreadText: # Hide (or disable) an entry field in CP depending on user group permission?
  
  (Asked by: username_0 on 2015-08-13)
  
  So I am trying to hide (or disable) a field in the "Edit Entry" view in the CP.
  
  I know how to test a user group :  
  `{% if currentUser.isInGroup('groupHandle') %}`
  
  But I cannot find a hook in Craft Doc to change the rendering of my field ?
  Perhaps with `getInputHtml()`? But I dont understand exactly how...
  
  **Tags:** plugin-development, control-panel, entries-field, permissions
  
  > **Comments:**
  > **username_0**: This is quite close to a solution : http://craftcms.stackexchange.com/questions/7084/get-the-current-entry-element-in-the-cp-edit-entry-view  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-08-13. Score: 4 | Accepted answer
  
  OK so here is my solution :  
  1/ define a custom permission for user groups
  
  ```
  public function registerUserPermissions()
  {
      return array(
          'updateTopNews' => array('label' => Craft::t('Update Top News')),
      );
  }
  
  ```
  
  2/ simply add css to hide the field when user has not the permission in my plugin init function
  
  ```
   public function init () {
      parent::init();
  
      $user = craft()->userSession->getUser();
      if ( craft()->request->isCpRequest() && $user ) {
  
          if ( !$user->can('updateTopNews') ) {
              craft()->templates->includeCss('#fields-topNews-field { display: none; }');
          }
      }
  
  ```
  
  > **Comments:**
  > **username_1**: You better don't tell them, they can give themselves the "permission" with the web inspector tools. ;)  
  > **username_0**: Yeah dont worry my user are not tech savy no prob on that ! :)  
  
  ---
  
  