How to expose a certain $user field in panel?

Back in the Kirby v2 era I created a plugin that showed certain data from a, well… Call it a superuser/admin, in this case it was me. My superuser blueprint contained some fields that I used to set up a subscription model; so I could easily set an end date for my customers and also an online payment link to iDeal (an online payment platform in the Netherlands).

Now I want to achieve the same result in v3; I have already been able to place the fields for a (fictitious) end date and payment link in the blueprint of the superuser, but I see no possibility to display these fields in Kirby’s panel.

Ideally I would also like to apply some (PHP) logic; only when the completed end date expires within 30 days this end date is relevant. In Kirby v2 I was able to do this well with some if and else stuff, but I’m afraid that this won’t work in a yml file.

In which direction should I look for a targeted solution? A plugin perhaps?

You can do that either via an info field or section or a custom section

Thanks for the info (and my apologies for the late response :see_no_evil:).

I’m currently working on a custom section for this, but now I’m wondering how I can retrieve data from a certain user’s fields in my index.php file, like for instance the website for user superuser?

<?php
	Kirby::plugin('dviate/dviate', [
		'sections' => [
			'dviate' => [
				'props' => [
					'headline' => function (string $headline) {
						return $headline;
					},
				],
				'computed' => [
					'greeting' => function() {
						date_default_timezone_set('Europe/Amsterdam');
						$currenthour = date('G');
						if ($currenthour >= 5 && $currenthour <= 11 ) {
							return 'Goedemorgen, ' . ucwords(get_current_user()) . '!';
						} else if ($currenthour >= 12 && $currenthour <= 18 ) {
							return 'Goedemiddag, ' . ucwords(get_current_user()) . '!';
						} else if ($currenthour >= 19 || $currenthour <= 4 ) {
							return 'Goedenavond, ' . ucwords(get_current_user()) . '!';
						}
					},
					'paymentDate' => function () {
						// return the field "paymentDate" from user "superuser" here
					},
					'paymentlink' => function() {
						// return the field "paymentLink" from user "superuser" here
					}
				]
			]
		]
	]);

With kirby()->user() you have access to the current user (and thus to the fields for that user). You can pass a user id as argument to get a specific user.

1 Like