Skip to content
Grav 2.0 is officially stable. Read the announcement →
Plugins

[PHP] using user data in plugin

Started by Tim 5 years ago · 1 replies · 531 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 Rene, 1 week ago
2 78 1 week ago
Plugins · by Xavier, 4 weeks ago
2 83 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1210 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 77 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 102 2 months ago