WordPress Plugins and Themes

Custom post type capabilities

6 Replies ·

  1. Hi Justin,

    I have created a custom post type named “conference” for which I would like to customize author’s (speaker’s) capabilities. Following your great post on mapping meta capabilities back in 2010 (http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types), I was able to set the edit_posts=>edit_conferences capability and prevent authors (speakers) from deleting their own conference by adding ‘delete_published_posts’=> ‘delete_published_conferences’ to the capabilities array. In addition, they cannot publish new conferences as they need to submit for review first.

    Now, I would like to go a little more granular but I don’t find the way :

    1) Prohibiting updating their conferences, i.e. forcing them to submit for review first;
    2) Allowing them to modify conference’s categories and tags and submitting the changes for review.

    Thanks in advance for pointing me in the right direction !

    Cheers !

    Patrick

  2. Justin Tadlock

    Sorry for the wait on the reply, Patrick. I’ve had a super busy last couple of days and am just now getting back into the swing of things.

    As far as I know, WordPress doesn’t have a native capability for submitting post updates for review once they’ve been published. That’d go for both your 1 and 2 questions.

    You’d need something like a publishing flow plugin. I’m not sure if Edit Flow handles that particular use case. Outside of that, I don’t know of any offhand that do that sort of thing. I’m sure there others.

    If you can, please drop into the Slack chat. Others hang out there and might have some suggestions.

  3. Patrick Sergerie

    Thanks Justin !

    Never looked at your Slack channel ! I’ll give it a shot… Need to familiarize myself with that tool though.

    And by the way, don’t be sorry for the delay, a 17 hours (8 business hours !) is quite a remarkable from my point of view !

    Cheers !

    Patrick

  4. Patrick Sergerie

    Hi Justin !

    Here a little piece of code to force speakers to submit for review when editing their conferences.

    Any advice ?


    add_action('post_updated', 'rc_post_pending', 10, 3); function rc_post_pending($post_ID) { if ( members_current_user_has_role( 'conferencier' ) ) { //Unhook this function remove_action('post_updated', 'rc_post_pending', 10, 3); return wp_update_post(array('ID' => $post_ID, 'post_status' => 'pending')); // re-hook this function add_action( 'post_updated', 'rc_post_pending', 10, 3 ); } }

    Patrick

  5. Justin Tadlock

    I’d think that code would unpublish the post by switching the status to pending. That would mean that the content would be temporarily taken down from your site for visitors. If that’s OK with you, it looks good from what I can see.

    I’m not sure that you’d want/need to re-hook the action. You might have to test both with and without.


    The reason for the Slack chat is that I know this particular discussion happened there once where folks were exploring some different options. So, I know there’s at least one or two people there that have at least attempted it. Not sure that they’ll be around in chat or not though.