<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>

CC BY-SA 3.0
2015-08-14T05:14:25.937Z
You better don't tell them, they can give themselves the "permission" with the web inspector tools. ;)
carlcs
CC BY-SA 3.0
2015-08-14T11:59:00.527Z
Yeah dont worry my user are not tech savy no prob on that ! :)
migmaker
CC BY-SA 3.0
2015-08-13T23:25:29.113Z
2015-08-13T23:25:29.113Z
migmaker
<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>

CC BY-SA 3.0
2015-08-13T23:20:38.883Z
This is quite close to a solution : http://craftcms.stackexchange.com/questions/7084/get-the-current-entry-element-in-the-cp-edit-entry-view
migmaker
<plugin-development><control-panel><entries-field><permissions>
Hide (or disable) an entry field in CP depending on user group permission?
# 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 ! :)  

---

