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 · 627 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 Vladimir Novak, 2 weeks ago
3 295 2 weeks ago
Plugins · by Mathieu Lecouturier, 3 weeks ago
3 277 3 weeks ago
Plugins · by Slebeig, 2 months ago
1 403 2 months ago
Plugins · by Rene, 2 months ago
2 574 2 months ago
Plugins · by Xavier, 3 months ago
2 490 3 months ago