I'll show a custom - error message.

function ccl($data, $postarr = '') {
 if($data['post_status'] == "publish"){
  $data['post_status'] = "draft"; 
  echo '<div id="my-custom-error" class="error fade"><p>Publish not allowed</p></div>';
 }  
  return $data;
}

add_filter( 'wp_insert_post_data' , 'ccl' , '99' );

I have try many thinks but each time successful message originates from wordpress the article released. Can one get rid of the success message and show my very own error message?

tanks for help...

You cannot print a mistake inside a [cde] filter since the user is rerouted soon after this. The very best factor to complete would be to hook in to the redirect filter and give a message variable towards the query string (this can overwrite any existing Wordpress message).

So, add the redirect filter inside your wp_insert_post_data filter function.

wp_insert_post_data

Adding a note variable within the redirect filter function.

add_filter('wp_insert_post_data', 'ccl', 99);
function ccl($data) {
  if ($data['post_type'] !== 'revision' && $data['post_status'] == 'publish') {
    $data['post_status'] = 'draft';
    add_filter('redirect_post_location', 'my_redirect_post_location_filter', 99);
  }
  return $data;
}

Finally hook in to the function my_redirect_post_location_filter($location) { remove_filter('redirect_post_location', __FUNCTION__, 99); $location = add_query_arg('message', 99, $location); return $location; } filter and add your message so Wordpress knows things to print.

post_updated_messages