Here's the code:
$immessage .= $txt['visual_received_warning'] .
"\n\n$scripturl?topic=$_REQUEST[topic].msg$_REQUEST[msg]#msg$_REQUEST[msg]"
. "\n\nThe Reason: ". $message ."\n\nCurrent Level: ". $_REQUEST['level'];
I'd like to add, within this string, if(empty($message)) ? '' : '\n\nThe Reason: ". $message .'
How do I do this?
I'd suggest reading up on Ternary Conditions (http://www.addedbytes.com/blog/code/ternary-conditionals/), which is what you're looking for...
tldr;
echo 'Hello ', $context['user']['is_logged'] ? 'Member!' : 'Guest', '!';
Now that I actually take a second to look at your code...
The Easiest Way:
$immessage .= $txt['visual_received_warning'] . "\n\n" . $scripturl . '?topic=' . $_REQUEST['topic'] . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'];
if (!empty($message))
$immessage .= "\n\n" . 'The Reason: ' . $message . "\n\n" . 'Current Level: ' . $_REQUEST['level'];
Since you're just adding something else to the string if a condition is evaluated as true, you can just concatenate it onto the end of the string.
More Difficult Way:
$immessage .= $txt['visual_received_warning'] . "\n\n" . $scripturl . '?topic=' . $_REQUEST['topic'] . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'] . (!empty($message) ? ("\n\n" . 'The Reason: ' . $message . "\n\n" . 'Current Level: ' . $_REQUEST['level']) : '');
I know how to use ternary conditions, but just not when variables are being assigned :-\
It's the same thing...there's no difference whatsoever.
Wonderful, it worked, thanks!
You are welcome! Have a good day!