Post status for roles

This topic contains 2 reply and 2 voices, and was last updated by Stepan 10 years, 1 month ago
Viewing 2 Posts - 1 through 2 (of 2 total)
Author Posts
March 20, 2014 at 5:21 pm 16980
Stepan Hi, small question - I'd like to have a possibility to allow users with certain roles to publish their posts without "pending" status. I mean, for example, user with role "Subscriber" is able to create a new post, but this post will have "pending" status, and then somebody from administration must approve it. And user with role "Author" also is able to create post, but his post must have status "published" at once. Is this possible?
March 20, 2014 at 6:11 pm 16983
Tareq Hasan Tareq Hasan

Yes, possible. Try this:

[php]
function dlp_wpuf_editor_post_status( $postarr ) {

$user = wp_get_current_user();
$role = reset( $user->roles );

if ( $role == ‘author’ ) {
$postarr[‘post_status’] = ‘publish’;
}

return $postarr;
}

add_filter( ‘wpuf_add_post_args’, ‘dlp_wpuf_editor_post_status’ );
add_filter( ‘wpuf_update_post_args’, ‘dlp_wpuf_editor_post_status’ );
[/php]

Insert this snippet to your themes functions.php

March 20, 2014 at 7:11 pm 16988
Stepan Stepan

It works! 🙂 thanks!

Viewing 2 Posts - 1 through 2 (of 2 total)