For a recent project, I was testing around with the possibilities to read userdata from logged in Kirby users. While doing so, I had a nice idea.

When I publish a new blogpost, I do this via Git most of the time. I've got a little workflow on my Mac, using Alfred to create a new post and copy all necessary files, like post-templates.

What is not included are images like a headerimage or an image for sharing on twitter and facebook. When I want to share the URL on twitter some days later, I often ask myself: did you upload an image for sharing?

So I thought, I want to see those information directly when looking at my post. Because they're not very interessting for the blogreader, I want the information to be visible only to me.

Getting userinformation

To select which user should see the information, I use the usermanagement of Kirby. A user who's logged in via the Panel, should see the information - no one else.

So I had to check if the current visitor is logged in, at first:

if($site->user()) {}

To be really sure, I want to limit the access to the information even more. Only logged in users with access to the Panel should see them. To ensure that, I extended my if-block:

<?php if($site->user() && $site->user()->hasPanelAccess()): ?>

And that's it! Using this if-block, I can show what ever information I think might be usefull. And only user which are logged in and do have panel access can see that information. In my case this look like that:

Infos on the page

What information you show is completely variable. But keep in mind: If you're using some kind of cache, this information might be cached and then everybody sees it!