wp update bulk status in user list
add_filter( 'handle_bulk_actions-edit-post', 'misha_bulk_action_handler', 10, 3 );
function misha_bulk_action_handler( $redirect, $doaction, $object_ids ) {
// let's remove query args first
$redirect = remove_query_arg( array( 'misha_make_draft_done', 'misha_bulk_price_changed' ), $redirect );
// do something for "Make Draft" bulk action
if ( $doaction == 'misha_make_draft' ) {
foreach ( $object_ids as $post_id ) {
wp_update_post( array(
'ID' => $post_id,
'post_status' => 'draft' // set status
) );
}
// do not forget to add query args to URL because we will show notices later
$redirect = add_query_arg(
'misha_make_draft_done', // just a parameter for URL (we will use $_GET['misha_make_draft_done'] )
count( $object_ids ), // parameter value - how much posts have been affected
$redirect );
}
// do something for "Set price to $1000" bulk action
if ( $doaction == 'misha_set_price_1000' ) {
foreach ( $object_ids as $post_id ) {
update_post_meta( $post_id, 'product_price', 1000 );
}
$redirect = add_query_arg( 'misha_bulk_price_changed', count( $object_ids ), $redirect );
}
return $redirect;
}