WordPress - How to sanitize multi-line text from a textarea without losing line breaks?
Since Wordpress 4.7.0
Use sanitize_textarea_field instead of sanitize_text_field
A more elegant solution:
update_post_meta(
$post_id,
'message',
implode( "\n", array_map( 'sanitize_textarea_field', explode( "\n", $_POST['message'] ) ) )
);
Use sanitize_text_field
if you want to sanitize text field.