Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

[PHP] using user data in plugin

Started by Tim 5 years ago · 1 replies · 708 views
5 years ago

Hi,

I am planning to use grav for internal purposes in my company.
Users login via Keycloak and get forwarded to grav.

My final goal is to show specific user related data from a variety of external databases.

To achieve this I created a plugin which can output php code in a twig template, like described in the docs.

To create the right queries, i will need user related data of the logged in user, e.g. user name or email.

So far i have tried to just pass on the username as a parameter to the function
{{ example_function( {{ grav.user.username }} ) }}
Unfortunately, this kind of nested use of the functions doesn't seem to be possible.

Is there a way to access the user data directly in my TwigExtension.php?

5 years ago

@stereo9:
{{ example_function( {{ grav.user.username }} ) }}

This should be

TWIG
{{ example_function(grav.user.username) }}

Suggested topics

Topic Participants Replies Views Activity
Plugins · by complanar, 2 weeks ago
6 349 1 week ago
Plugins · by BenLaKnet, 2 weeks ago
1 170 2 weeks ago
Plugins · by complanar, 1 month ago
2 452 4 weeks ago
Plugins · by Vladimir Novak, 2 months ago
3 738 2 months ago
Plugins · by Mathieu Lecouturier, 2 months ago
3 578 2 months ago