• Resolved jradford

    (@jradford)


    I wanted to have a user role that wouldn’t be able to publish or edit published posts/pages, but would be able to create a revision (as a draft), edit it and then submit for publishing. I thought that someone with edit_posts and without edit_published_posts or publish_posts would be able to do that. But, it seem that you won’t display the revisionize link in the admin actions on posts unless they can also edit the post directly (checks in is_create_enabled). This seems like an odd default, since creating a revision doesn’t imply you can publish it and replace the original.

    So, I wanted to first confirm that this was the intended default behavior. Secondly, I wanted to provide the code we used to modify the behavior to what we were expecting, in case others had need:

    
    add_filter('revisionize_is_create_enabled', 'hc_can_revisionize');
    function hc_can_revisionize($is_enabled, $post) {
      if (! $is_enabled) {
        $is_enabled = !\Revisionize\get_revision_of($post) && current_user_can('edit_posts');
      }
      return $is_enabled;
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author jamiechong

    (@jamiechong)

    This is actually intended. Because think about what happens when a revision is published – it’s overwriting/editing its parent post. So if a user can’t edit the main/parent post, then by default I don’t let them revisionize it. Your solution should work for Contributors, but it won’t work for Authors.

    I’m actually working on a paid addon right now that will allow for this functionality in a more robust way, but it sounds like you’re a developer and can probably figure out a solution that works for you.

    Thread Starter jradford

    (@jradford)

    Thanks, I see the use case now. I always forget about the author role, as we have no use for it in our organization.

    Plugin Author jamiechong

    (@jamiechong)

    You’ve probably seen it already, but there’s a new addon system along with an addon that allows contributors to create revisions. https://revisionize.pro/downloads/contributors-can/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘create revision when user cannot edit published’ is closed to new replies.