thomaspark / snowball

A WordPress plugin for making immersive longform articles

Home Page:https://snowball.openhtml.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use capabilities on snowball post type?

noelforte opened this issue · comments

Hi guys,

I've made a modification to the snowball plugin and added custom capabilities so that only certain roles can actually publish posts. Rather than assign the capabilities to the roles in the plugin itself, I'm using the Members plugin on The Triangle site to add the capabilities to roles, but obviously you'd want to bind the roles and capabilities directly in the plugin code if this ever went to production. Here's what I've done on my own copy of snowball:

screen shot 2016-01-22 at 12 27 35 am

Snowball articles have the ability to become vastly different than articles using custom built templates, because well...they can use a completely different template, or look completely different from the rest of the site when published. By using custom capabilities and assigning them to the default roles that have the ability to publish posts the average user won't see any difference in their experience, but for us that want to have a bit more control, this keeps us from having to modify the plugin to add the custom capabilities.

Hey @noelforte, thanks for the suggestion. If I understand correctly, you want more fine-grained control over user capabilities with Snowball articles. Someone who can edit regular posts, you might not want to be able to edit Snowball articles...

And by defining capabilities when registering the Snowball custom post type, you're able to use the Members plugin to get this fine-grained control over the capabilities that different roles get?

How about if we just added the capabilities array like you did? This would provide a hook for organizations to use with Members plugin or similar, without overreaching and defining our own roles that users may not want.

Hi @thomaspark, that would probably work.

Here's what I used as a reference: https://codex.wordpress.org/Function_Reference/register_post_type#capability_type and https://codex.wordpress.org/Function_Reference/register_post_type#capabilities

Of course, like I said, you'd also need to bind them to at least one of the default roles, as once you add the capabilities any roles needing access to the snowball type will need to have those capabilities set, so that the plugin can function out of the box. See: https://codex.wordpress.org/Function_Reference/add_cap

Hey @noelforte, I've added custom capabilities and assigned them to default roles as you suggested. These changes are committed to develop branch and will be included in the next release.

If you have the chance, please check out the changes in commit af7cb71 and test them on your end. Hopefully this eliminates the need for you to modify each new release. Thanks for the suggestion.