(SMF 2.0.xx Only)
This code is for users who want to trim any whitespace from either side of the " subject title " and remove any blank lines from the start -and- end of the message body.
Sources\Post.php
Find:
// Collect all parameters for the creation or modification of a post.
$msgOptions = array(
'id' => empty($_REQUEST['msg']) ? 0 : (int) $_REQUEST['msg'],
'subject' => $_POST['subject'],
'body' => $_POST['message'],
Replace:
// Collect all parameters for the creation or modification of a post.
$msgOptions = array(
'id' => empty($_REQUEST['msg']) ? 0 : (int) $_REQUEST['msg'],
'subject' => trim($_POST['subject']),
'body' => preg_replace('/^(\s*<br\s*\/?>\s*)+|(\s*<br\s*\/?>\s*)+$/', '', $_POST['message']),
This code will trigger when creating new messages and modifying them.