How to give a custom user role permission to arrange folders?
-
I have a custom user with specific permissions, now I would like them to be able to arrange items in folders. How do I give that user role permission to use your plugin?
-
Hi @kevidoss,
My guess is that it will depend on how you have this set up and which plugin you’re using to manage permissions. Wicked Folders uses the built-in WordPress taxonomy API so I believe you should be able to assign capabilities like assign_terms, edit_terms, etc. to the user for the folder taxonomies.
If needed, you can also use the registered_taxonomy action to alter the folder taxonomies with custom capabilities.
Hope this helps! Feel free to post any other questions you have.
I’m not using a plugin to manage permissions. I’ve made a custom WordPress theme, so I just added a new user role (and removed most of the standard ones) in my functions.php file.
So yes, assigning capabilities should work fine. The only problem is, I don’t know which specific capabilities I need for you plugin. Are the “assign_terms” and “edit_terms” capabilities you have used and if this is the case, did you use any other ones that I should add to give my user access?
The plugin currently does not explicitly set the capabilities for the folder taxonomies. I believe they inherit the four built-in capabilities defined by WordPress (i.e. ‘manage_terms’, ‘edit_terms’, ‘delete_terms’ and ‘assign_terms’); however, if I’m not mistaken, I believe those capabilities map to ‘manage_categories’ (with the exception of ‘assign_terms’ which maps to ‘edit_posts’).
So, for example, if you use the add_cap function to add the ‘manage_categories’ capability to your custom role, they should be able to manage folders.
I assume that is probably more broad than you want though. If that’s the case, you’d need to first alter the folder taxonomy by adding custom capabilities to it and then add those custom capabilities to your custom role. For example, you could set ‘manage_terms’ to ‘manage_folders’ and then assign ‘manage_folders’ to the role. Does that make sense?
That would actually be fine, so I just tried adding the ‘manage_categories’ to my ‘functions.php’ file but sadly that didn’t work. The entire folders structure is still invisible. I also tried adding the capabilities separately (manage_terms, etc) but that also didn’t help. Any more ideas I could try?
Can you give me a bit more information on how you have this set up? Did you use the add_role function to create the custom role for this user? If so, are you assigning the ‘manage_categories’ capability via the add_role function or the add_cap function? Or are you using a different approach?
Also, are you trying to give the user access to folders for pages, posts or a custom post type?
You noted that the folder structure is invisible. Are you seeing the folder pane to the left of the posts list but without the folders? Is the folder toolbar that allows you to add, edit and delete folders showing up? If so, what happens if you try to add a folder?
Thanks!
//standaard user roles verwijderen remove_role( 'subscriber' ); remove_role( 'editor' ); remove_role( 'contributor' ); remove_role( 'author' ); //nieuwe user roles toevoegen add_role('leerkracht', __( 'Leerkracht'), array( 'read' => true, // Allows the user to read 'create_posts' => true, // Allows user to create new posts 'edit_posts' => true, // Allows the user to edit their own posts 'edit_others_posts' => true, // Allows the user to edit others posts too 'publish_posts' => true, // Allows the user to publish posts 'upload_files' => true, // Allows the user to upload files 'delete_posts' => true, // Allows the user to delete posts 'edit_published_posts' => true, // Allows the user to edit published posts 'manage_terms' => true, // Allows the user to manage categories 'edit_terms' => true, // Allows the user to manage categories 'delete_terms' => true, // Allows the user to manage categories 'assign_terms' => true, // Allows the user to manage categories ) );
This is the code I used in my ‘funtions.php’ file to remove standard roles and add my custom role. This could be the wrong way to add the ‘manage_terms’ etc. I wasn’t completely sure what you meant (but I figured, since it works for the other capabilities why wouldn’t this)
The only thing I use your folders for is to organise posts (so the pages and custom post are not enabled in the settings of your plugin).
And yes, there is a large empty space (where the folders are visible in my admin account) and I also see the button in the top bar to toggle that panel (but this also doesn’t work unless I’m using my admin account). And no, the toolbar is also missing. It’s just a large empty space, so I also can’t add or remove folders. I hope this clears things enough to give you the right idea ??
Thanks for the additional info! This was very helpful and I was able to track down the issue. The problem actually had to do with a small bug in the plugin caused by a user setting not being properly initialized in some instances.
I’ve fixed the issue and I believe it should resolve the issue for you once you update to 2.8.3. Want to try updating the plugin and letting me know if it’s fixed for you?
Great! It’s fixed now. Thanks for your help ??
Great! Thanks for marking the issue as resolved and let us know if we can help with anything else.
- The topic ‘How to give a custom user role permission to arrange folders?’ is closed to new replies.