Dave's code should work fine - ours is almost the same and it works.
// --------------------------------------------------------------------<br /> $html = new html;<br /> if (!$user['U_Username']) {<br /> $html -> not_right($ubbt_lang['LOGIN_OR_REG'],$Cat);<br /> }
and in language/generic.php we have:
$ubbt_lang['LOGIN_OR_REG'] = "Please <a href='login.php'>login</a> or <a href='newuser.php'>register</a> to use this function.";
(Because if we don't provide the link to login or register, I inevitably get people emailing me asking how.
)
Just a note though - it doesn't disable the search at the bottom of the postlist page. They can still search each forum individually. We don't disable that because hopefully some people use it to prevent duplicate posts.