@seriousdon you’d need another forward slash in front of your comment before the code like so http://pastebin.com/HSpJNLyV
In order to place the dynamic profile link at the beginning of the menu change this following line from
$menu = $menu . $profilelink;
to
$menu = $profilelink . $menu;