3

Is there a way to hide a section from the Entries tab based on user permissions? Whether it means creating a user permission in a plugin, or hiding the section selection tab from Entries altogether.

I have a channel that users with a certain permission can create entries in using a front-end form. Once created, I don't want the user to see the entry in the CP or to have the ability to edit it.

I'd like to still allow them to see other entries in the "All entries" tab, so my original plan to hide these sections through CPCSS doesn't work. Any other ideas?

3

There’s no way to give a user group permission to create entries but not see those entries they created in the CP.

The only way to achieve what you want would be to write a plugin that provides its own “save-entry” controller action, which allows users to create the entries without actually having the permission. The Guest Entries plugin would be a good starting point - it has a GuestEntriesController with an actionSaveEntry() method that behaves very similar to Craft’s built-in EntriesController::actionSaveEntry(), but it skips the normal permission-based authorization logic.

In your case you might still want some level of authorization. For example, you can verify that there’s a currently logged-in user, and that they belong to a certain group. If that’s the case you’ll want to not add this line:

protected $allowAnonymous = true;

And at the top of your actionSaveEntry() method, add this:

$user = craft()->userSession->getUser();

if (!$user->isInGroup('authors'))
{
    throw new HttpException(403, Craft::t('This action may only be performed by authors.'));
}
2

Under Settings/Users, you can create user groups and set what each different group has access to. So if there is a channel or section you don't want one group touching, then you can toggle it off for that group.

  • Well, I'm using an entry form, so the user needs the permission to create entries in that channel or it won't save (I think). If I didn't need to have that permission on, I'd turn it off to hide the entries from them.Another issue, is that I need these entries to be tied to this user, so I'm using their ID to set them as the author. I guess I could use the Guest Entries plugin and use their ID into a related field, but I was hoping for something on the side of viewing the entries in the CP, than changing out the form controller. – Will Browar Jun 24 '15 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.