For running J!5.1 you must https://fabrikar.com/forums/index.php?wiki/update-from-github/ or include the new file manually https://fabrikar.com/forums/index.php?threads/joomla-5-1-and-fabrik-cannot-find-files-error.54473/post-285151 See also Announcements
Please see our announcement here.
$user = JFactory::getUser();
if($user->get('guest') == 1)
{
$app = JFactory::getApplication();
$url = 'url_of_your_registration_form';
$msg = 'You have to be registered to fill this form';
$app->redirect($url, $msg);
}
So why do you show the menu item to the public user? Set the menu access to registered.If the user clicking the menu is registered, then he can see the form. If he is not registered, then he can't see the form.