How to make an edit to an already published post back to Draft

Add below code in your current theme’s functions.php file.

You have to replace USER ROLE with your user role name in if condition.

function check_edit_post($post_id){
 global $post;

  if( in_array('USER ROLE', wp_get_current_user()->roles) && 'product' == get_post_type($post_id) && 'publish' == get_post_status($post_id) && $post->post_date != $post->post_modified ){

     wp_update_post(array(
       'ID'    =>  $post_id,
       'post_status'   =>  'draft'
     ));
  }
}
add_action( 'save_post', 'check_edit_post' );

Hope this will helps you.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)