fix profile page server error for anonymous users (fixes #2356)

same pull request as 2357 but cleaner...