@timmyquivy it would be good if the above two lines were changed to:

    $app = F::app();
    $title = $app->wg->Title;
    $user = $app->wg->User;

And replace all instances of $wgUser with $user.