I’m using the PublishPress Permissions / PublishPress Capabilities plugin.
My Author users have the edit_published_posts permission enabled, but the publish_posts permission is disabled. However, I do want them to be able to UNPUBLISH their posts.
However, one of my Author users just let me know that there seems to be a bug where he is given the option to set his already published post to Draft inside the post editor, but that when he clicks Update, it reverts back to Published status.
I tested it myself and I am also having the same problem when logged in as an Author. When I’m logged in as Admin, I can set an already published post to Draft successfully.
I read in this document:
https://aoh.org.uk/wp-content/plugins/capability-manager-enhanced/readme.txt
from:
1.8 – 24 Oct 2019 =
the text:
* Feature : Work around WordPress issue allowing users with edit_published_posts (but not publish_posts) to unpublish published posts
So that is what I need, but I’m not sure what I need to do inside PublishPress Permissions in order for this to start working on my site.
Thank you for your assistance!
Amy
]]>Thank you so much for adding back the work-around for the current WP bug on the edit_published_posts when post status is “Published”. I really really appreciate it b/c an important project I’m working on won’t work or move forward without that fix. So thank you! In the meantime, looks like WP may be releasing the patch in 5.4 (hoping).
That said, I can’t tell, but I think the work-around for this in PublishPress Capabilities v1.9 (latest as of today) may have implemented a new issue where an Author can’t unpublish a post, or set the post from Publish to Draft status.
I may be mistaken, but wanted to bring it to your attention to double-check and maybe you can let me know if that’s the case or if it’s something else.
Thanks so much again. Huge appreciation.
Amy
]]>Is it possible to have the following setting? I want to set a user for both of the followings:
1. Write a post draft, but can’t publish (so only has “Submit for Review” button).
2. Edit his own published posted (done by his own account), but still can’t update live, can only “Submit for Review” after edit
So I’ve turned off “publish_posts”, and turn on “edit_published_posts”. But then I find can do (1) above, but for (2), they are able to update published post directly and publish live.
How can I change the setting to what I want? Thanks.
https://www.ads-software.com/plugins/user-role-editor/
]]>edit_published_posts
Since 2.0
User can edit their published posts. This capability is off by default.
The core checks the capability edit_posts, but on demand this check is changed to edit_published_posts.
However I did not find where I could change this. Is it in a php file? Do I add a filter to functions.php? Is it set in Mysql?
I really would like to avoid using another plugin.
regards
]]>Some code to replicate the problem:
// in wp-config.php: define('WP_DEBUG', true);
add_action( 'init', 'sample_cpt' );
function sample_cpt() {
// Register New Post Type
$args = array(
'public' => true,
'label' => 'Events',
'supports' => array('title', 'editor', 'page-attributes'),
'capabilities' => array(
'edit_post' => 'edit_event',
'read_post' => 'read_event',
'delete_post' => 'delete_event',
// etc.
//'edit_published_posts' => 'edit_published_events'
)
);
register_post_type( 'events', $args );
// normally might add_cap() to roles here
// Create example post
$example_post_exists = get_page_by_title('example post', 'object', 'events');
if ( !$example_post_exists ) {
$example_post = array(
'post_content' => 'example post content',
'post_status' => 'publish',
'post_title' => 'example post',
'post_type' => 'events'
);
wp_insert_post($example_post);
}
}
// Go view php notice on admin edit posts page for new Events cpt
As expected, the notice does not display if you uncomment the 'edit_published_posts' => 'edit_published_events'
in the ‘capabilities’ code above. I think the capability 'edit_published_posts'
would normally be set by default, unless omitted in an explicit declaration of the capabilities, like my example above. I’ve come across a plugin for which this was the case.
To get rid of the notice, I’ve altered the file co-authors-plus.php on line 1075
if ( 'publish' == get_post_status( $post_id ) /*&& ! empty( $obj->cap->edit_published_posts)*/ && ! empty( $current_user->allcaps[$obj->cap->edit_published_posts] ) )
I added the conditional inside the commented section (/*conditional*/). Uncomment it and the notice no longer displays. The same thing could probably be done on line 1077.
Feedback welcome. Thanks for a great plugin!
https://www.ads-software.com/extend/plugins/co-authors-plus/
]]>It’s quite easy to reproduce, so here’s what I’ve done. On the blog we have a lot of authors. All those authors have the same role with the same capabilities: they MAY NOT publish posts directly (capability: publish_posts), but they MAY edit their own posts afterwards (capability: edit_published_posts). This last one seems to be causing the problem, here’s what happends:
When an author is writing a new post, and the post is saved (auto-save or manually) BEFORE pushing the “Submit for Review” button, the post is published directly, without getting the pending status. This only happens when the post is saved before submitting it.
At first I thought it was a bug in the Role Manager plugin we were using, but when I disable “edit_published_posts” this problem disappears and posts get the pending status even when it’s saved.
I think I fixed it now by hacking /wp-admin/includes/post.php right below line 71.
// START fix
if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' )) {
$_POST['post_status'] = 'pending';
}
// END fix
But I really don’t like hacking. So can anyone besides me confirm that this is in fact a WordPress bug?