I don't get any error (nor the grav log or php log) but probably I don't understand exactly how it goes in admin part when you are not login.
In my case it seems that all plugins are loaded and initialised (not sure but...) before the global system check about the login.
Therefore in my plugin as I have
public function onPluginsInitialized(): void
{
if ($this->isAdmin()) {
$this->enable([
'onAdminMenu' => ['onAdminMenu', 0],
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
'onPagesInitialized' => ['onPagesInitialized', 0],
'onAdminTaskExecute' => ['onAdminTaskExecute', 0],
]);
}
}
it directly goes to onPagesInitializer and perform the code. Of course it fails because of a redirection to a page unreachable as the unlog blocks it.
if ($uri->path() === '/admin/pagetransfer') {
$page = new \Grav\Common\Page\Page();
$page->init(new \SplFileInfo(__DIR__ . '/pages/admin/pagetransfer.md'));
$page->template('pagetransfer'); // Use template Twig `pageTransfer.html.twig`
$this->grav['page'] = $page;
}
So I don't know if it's the right thing to do, but changing to this finally made the job:
public function onPluginsInitialized(): void
{
if ($this->grav['user']->authenticated && $this->isAdmin()) {
You confirm this is the right thing to do ? 🤔