Change post status if usergroup = admin

This topic contains 5 reply and 2 voices, and was last updated by Sparhamster 11 years ago
Viewing 5 Posts - 1 through 5 (of 5 total)
Author Posts
April 17, 2013 at 10:22 pm 2395
Sparhamster Hi, hopefully my last problem / question ;) if a user post an article from a form which get the status "pending", the post will also be "pending" if the user edit this article. thats good ;) but its not good, that the status will switch from "published" to "pending" if a admin will edit the article over the wpuf edit form. How can i change the post status in a filter? if the usergroup = "admin" the post status has to set from "pending" to "published". i work with that function in the functions.php function get_user_role() { global $current_user; $user_roles = $current_user->roles; $user_role = array_shift($user_roles); return $user_role; } so i get the user_role with get_user_role() and the output is for example "administrator" ;) thx!
April 17, 2013 at 10:51 pm 2397
Tareq Hasan Tareq Hasan

Pasting code directly from a project, might help 😉

[php]
function dlp_wpuf_editor_post_status( $postarr ) {

if ( dlp_is_admin() || dlp_is_editor() ) {
$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]

April 17, 2013 at 10:59 pm 2398
Sparhamster Sparhamster This reply has been marked as private.
April 17, 2013 at 11:05 pm 2399
Sparhamster Sparhamster

hm..it wont work… the submit / edit button is loading and loading … 🙁

April 17, 2013 at 11:07 pm 2400
Tareq Hasan Tareq Hasan

My example is also got two different user roles, perhaps some PHP errors came up in your case. Fix your code.

April 17, 2013 at 11:19 pm 2401
Sparhamster Sparhamster This reply has been marked as private.
Viewing 5 Posts - 1 through 5 (of 5 total)