admin管理员组文章数量:1416651
I would like to allow a WordPress contributor to change a draft page Submitted for Review back to a draft page without giving the contributor the capability to publish pages. I have tried without success:
function post_pending ( $new_status, $old_status, $page ) {
if ( $old_status == 'draft' && $new_status != 'pending' ) {
edit_post_link();
}
}
if ( current_user_can( 'contributor' ) ) {
add_action( 'transition_post_status', 'post_pending', 10, 3 );
}
Any help would be appreciated.
I would like to allow a WordPress contributor to change a draft page Submitted for Review back to a draft page without giving the contributor the capability to publish pages. I have tried without success:
function post_pending ( $new_status, $old_status, $page ) {
if ( $old_status == 'draft' && $new_status != 'pending' ) {
edit_post_link();
}
}
if ( current_user_can( 'contributor' ) ) {
add_action( 'transition_post_status', 'post_pending', 10, 3 );
}
Any help would be appreciated.
Share Improve this question edited Nov 30, 2015 at 7:04 Mayeenul Islam 12.9k21 gold badges85 silver badges169 bronze badges asked Nov 30, 2015 at 1:58 user3166179user3166179 12 bronze badges 1- I just wanted to pop in and say that as of Wordpress 4.9 this solution still works. – Stephen Petrey Commented Dec 7, 2017 at 20:19
1 Answer
Reset to default 1This is not a permissions issue - contributors can (by default) change a post from pending to draft. To test, submit a post for review, then "quick edit" it - you'll see that you're able to change the status back to draft.
The issue is that the "save as draft" button in the UI is hidden once a post is submitted for review - let's "restore" it:
function wpse_210259_revert_to_draft_button() {
global $post;
$post_type = get_post_type_object( $post->post_type );
if ( $post->post_status === 'pending' && ! current_user_can( $post_type->cap->publish_posts ) ) {
printf(
/**
* Since there are no hooks where the original "Save Draft" button
* appears, use CSS positioning to "fake" it to give the user a
* consistent UI.
*/
'<button style="position: absolute; top: 10px; left: 10px;" class="button" type="submit" name="post_status" value="draft">%s</button>',
__( 'Save as Draft' )
);
}
}
add_action( 'post_submitbox_misc_actions', 'wpse_210259_revert_to_draft_button' );
本文标签: post statusSubmitted for Review back to a Draft page
版权声明:本文标题:post status - Submitted for Review back to a Draft page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745255718a2650087.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论