<p>Impossible out of the box – there's no permission setting for ordering Structures. For now, I'd <a href="https://craftcms.uservoice.com/forums/285221-feature-requests" rel="nofollow noreferrer">add a feature request</a> and hack it in.</p>

<p>The easiest solution is probably to use the <a href="https://github.com/lindseydiloreto/craft-cpbodyclasses" rel="nofollow noreferrer">CP Body Classes</a> and <a href="https://github.com/lindseydiloreto/craft-cpcss" rel="nofollow noreferrer">CP CSS</a> plugins to hide the <code>a.move.icon</code> element (like you say) based on the current user's user group affiliation(s).</p>

<p>Personally I wouldn't worry too much about the longevity of such a hack; if it ever breaks (due to future DOM structure changes in the CP) it's probably not a huge problem, beyond the fact that your user group will be able to reorder Structures while you find another solution. Also, with a little luck your feature request gets implemented sooner or later.</p>

CC BY-SA 3.0
2016-11-16T21:08:35.247Z
Thanks a lot! You make a good point going for the easier solution since it's a quick fix and it might be a while before there are breaking changes to the DOM. I'll probably take the more official option as Mike Pepper suggested, but this is a good alternative, too.
Aaron Bushnell
CC BY-SA 3.0
2016-11-16T21:10:24.437Z
Yeah, Mike's answer should be the correct one – you should probably hide the move icon either way, but as long as you're writing your own plugin it makes sense to do it without CP CSS and CP Body Classes :)
Mats Mikkel Rummelhoff
CC BY-SA 4.0
2019-03-25T14:23:31.890Z
Has any thing happened with this? Did Craft add this functionality?
mateostabio
CC BY-SA 3.0
2016-11-16T09:42:39.960Z
2016-11-16T09:42:39.960Z
Mats Mikkel Rummelhoff
<p>You should be able to ensure that the elements aren't moved by using the <a href="https://craftcms.com/docs/plugins/events-reference#structures-onBeforeMoveElement" rel="nofollow noreferrer">structures.onBeforeMoveElement</a> hook in a plugin:</p>

<pre><code>public function init()
{
    craft()-&gt;on('structures.beforeMoveElement', function(Event $event)
    {
        $user = craft()-&gt;userSession-&gt;getUser();

        if (!$user-&gt;isInGroup('allowedGroup'))
        {
            $event-&gt;performAction = false;
        }
    });
}
</code></pre>

<p>I've had a quick look through the source but I'm not 100% sure if this is also run when an element's parent is changed. I would think it is.</p>

<hr>

<p>You could also create your own custom user permission that can be assigned to individual users or multiple groups for more flexibility:</p>

<pre><code>public function init()
{
    craft()-&gt;on('structures.beforeMoveElement', function(Event $event)
    {
        $user = craft()-&gt;userSession-&gt;getUser();

        if (!$user-&gt;can('pluginName-moveElements'))
        {
            $event-&gt;performAction = false;
        }
    });
}

public function registerUserPermissions()
{
    return array(
        'pluginName-moveElements' =&gt; array('label' =&gt; Craft::t('Move Elements in Structures')),
    );
 }
</code></pre>

CC BY-SA 3.0
2016-11-16T21:07:03.327Z
Thanks so much, Mike! I'll look into this option as it seems a bit more official and less of a hack.
Aaron Bushnell
CC BY-SA 3.0
2016-11-16T11:30:56.470Z
2016-11-16T12:11:31.870Z
2016-11-16T12:11:31.870Z
Mike Pepper
<p>I need to create a plugin that prevents select user groups from reordering a Structure content type in the Entries listing. I could quickly do this by just hiding the <code>a.move.icon</code> element, but I worry about the longevity of this solution. For example, if this class were to change then the plugin wouldn't hide the element any longer.</p>

<p>Is there a better, more long-term fix that someone might recommend here? </p>

<plugin-development><structure>
How to prevent select user groups from reordering structures
# How to prevent select user groups from reordering structures

(Asked by: username_0 on 2016-11-16)

I need to create a plugin that prevents select user groups from reordering a Structure content type in the Entries listing. I could quickly do this by just hiding the `a.move.icon` element, but I worry about the longevity of this solution. For example, if this class were to change then the plugin wouldn't hide the element any longer.

Is there a better, more long-term fix that someone might recommend here?

**Tags:** plugin-development, structure

---

## 2 answers

### Answer by username_3 on 2016-11-16. Score: 4 | Accepted answer

You should be able to ensure that the elements aren't moved by using the structures.onBeforeMoveElement hook in a plugin:
public function init()
{
    craft()->on('structures.beforeMoveElement', function(Event $event)
    {
        $user = craft()->userSession->getUser();

        if (!$user->isInGroup('allowedGroup'))
        {
            $event->performAction = false;
        }
    });
}

I've had a quick look through the source but I'm not 100% sure if this is also run when an element's parent is changed. I would think it is.

You could also create your own custom user permission that can be assigned to individual users or multiple groups for more flexibility:
public function init()
{
    craft()->on('structures.beforeMoveElement', function(Event $event)
    {
        $user = craft()->userSession->getUser();

        if (!$user->can('pluginName-moveElements'))
        {
            $event->performAction = false;
        }
    });
}

public function registerUserPermissions()
{
    return array(
        'pluginName-moveElements' => array('label' => Craft::t('Move Elements in Structures')),
    );
 }

> **Comments:**
> **username_0**: Thanks so much, Mike! I'll look into this option as it seems a bit more official and less of a hack.  

---

### Answer by username_1 on 2016-11-16. Score: 3

Impossible out of the box – there's no permission setting for ordering Structures. For now, I'd [add a feature request](https://craftcms.uservoice.com/forums/285221-feature-requests) and hack it in.

The easiest solution is probably to use the [CP Body Classes](https://github.com/lindseydiloreto/craft-cpbodyclasses) and [CP CSS](https://github.com/lindseydiloreto/craft-cpcss) plugins to hide the `a.move.icon` element (like you say) based on the current user's user group affiliation(s).

Personally I wouldn't worry too much about the longevity of such a hack; if it ever breaks (due to future DOM structure changes in the CP) it's probably not a huge problem, beyond the fact that your user group will be able to reorder Structures while you find another solution. Also, with a little luck your feature request gets implemented sooner or later.

> **Comments:**
> **username_0**: Thanks a lot! You make a good point going for the easier solution since it's a quick fix and it might be a while before there are breaking changes to the DOM. I'll probably take the more official option as Mike Pepper suggested, but this is a good alternative, too.  
> **username_1**: Yeah, Mike's answer should be the correct one – you should probably hide the move icon either way, but as long as you're writing your own plugin it makes sense to do it without CP CSS and CP Body Classes :)  
> **username_2**: Has any thing happened with this? Did Craft add this functionality?  

---

