[wp-hackers] Custom Post Type with contributor-like capabilities?

Andrew Nacin wp at andrewnacin.com
Fri Jun 25 21:27:46 UTC 2010


On Fri, Jun 25, 2010 at 4:16 PM, Jake Goldman <
wphackers at jakemgold.myfastmail.com> wrote:

>  I'm attempting to create a custom post type "guest blogs" with a
> contributor-like custom role, "guest blogger".
>
> When registering the custom post type, I pass a custom capability for
> "edit_posts" using the "capabilities" argument ("guest_blog"). The "guest
> blog" capability is added to the new custom "guest blogger" role, as well as
> a few other roles (like administrator).
>

If you use a capability type like "gpost", which defaults to "post" then
WordPress will automatically generate the edit_gposts, publish_gposts,
delete_gposts (etc) capabilities for you. Additionally, it will know how to
properly handle the edit_gpost, publish_gpost, and delete_gpost meta
capabilities.

If you want finer grained control, you can individual name each of the
capabilities WP would otherwise generate for you based on the capability
type.

See register_post_type() and get_post_type_capabilities(), in
wp-includes/post.php.


More information about the wp-hackers mailing list