I've no experience with PHP and GD, so it may be wrong.
In your code, from PHP.net, you have first a variable, $text, with some text. hen your wordwraps it, and get a new text into the variable $newtext. In the other code, from this tutorial, you also need some text. The text is used in imagettfbbox() and imagettftext(). They both use the variable, $text, with is the content of the GET, "text". Because of that, you simply have to wordwrap that variable, and then then text of it will be used in the following code.
Code:
<?php
header('Content-type: image/png');
// ------------------------------------------------------
// This is the changed line...
$text = wordwrap($_GET['text'], 20, "<br />\n");
// ------------------------------------------------------
$im = imagecreatefrompng ("userbar.png");
$color = imagecolorallocate($im, 0, 0, 0);
$font = 'font.ttf';
$fontsize = 6;
$size = imagettfbbox($fontsize, 0, $font, $text); //calculate the pixel of the string
$dx = (imagesx($im)) - (abs($size[2]-$size[0])) - 20; //calculate the location to start the text
imagettftext($im, $fontsize, 0, $dx, 13, $color, $font, $text);
imagepng($im);
imagedestroy($im);
?>