[wp-testers] Custom post type capabilities not fully set up on registration

Andrew Macaulay-Brook am at theburo.net
Thu Oct 21 11:08:46 UTC 2010


I can't work out whether this is covered by http://core.trac.wordpress.org/ticket/14122 or not.

I'm using a custom post type called property, assigning capabilities using 'capability_type' => 'property' and then giving my Editors *_property and *_propertys capabilities wherever I can see they already have *_post or *_posts.

The rationale for all this is that it lets me turn off all the capabilities for blog Posts, hiding the Posts menu for Editors, as this site doesn't use the blog.  I then give my client an Editor level login.

I'm mapping meta-capabilities using Justin Tadlock's code at http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types

Problem: Neither my clients, nor the Admin login can Trash custom posts.

It seems that using the argument 'capability_type' => 'property' only sets up the following mappings in the post type object:

<!-- Capability mapping: stdClass Object
(
    [edit_post] => edit_property
    [edit_posts] => edit_propertys
    [edit_others_posts] => edit_others_propertys
    [publish_posts] => publish_propertys
    [read_post] => read_property
    [read_private_posts] => read_private_propertys
    [delete_post] => delete_property
)
 -->

... which I generated using $post_type = get_post_type_object( $post->post_type ); print_r($post_type->cap);

It looks like the mappings for $post_type->cap->delete_posts and $post_type->cap->delete_others_posts aren't being set up.

I've got an issue with taxonomy capabilities too, but that's my next job.

Andrew Macaulay-Brook, BEng MBCS CITP, trading as theburo.net
mailto:am at theburo.nethttp://www.theburo.net/



More information about the wp-testers mailing list