What's wrong with the way I use variables in my function?
For a variable to be available in the scope of a function, it needs to have been initialised (or it needs to have been initialised in the global scope and imported into the local function using global).

At the moment there's nothing declaring or passing the $vars variable in...it hasn't been initialised, thus you get the warning.

You're passing a variable to the function called $message, which suggests your code should be:

$uid = $message-&gt;author-&gt;uid;


The confusion with $vars/$variables might be caused by the fact that it's sort of the standard name for the only argument passed to theme functions, e.g.

function MYTHEME_preprocess_node(&amp;$vars) {
  // Use $vars