The existing php code is in the vbulletin files. Did you try a search in the files for fetch_userinfo? It shows up many times and you can see the use of it. These are some excepts from a page I use:
First the cleaner is used on the userid that is passed from the form:
PHP Code:
$vbulletin->input->clean_array_gpc('r', array(
'f' => TYPE_UINT,
'do' => TYPE_STR,
'u' => TYPE_UINT,
));
then the userinfo is obtained a few lines after and I grab the username (and other stuff later):
PHP Code:
$userinfo = fetch_userinfo($vbulletin->GPC['u']);
$username = $userinfo['username'];
Take a look at the function itself to see all the info obtained in the query - in includes/functions.php
There are articles you can read on the user of the vbulletin cleaner and on writing secure code.