Jump to content

Access user Language in init() / before ready()


Noel Boss
 Share

Recommended Posts

Hi Folks

I want to access $user->language inside the init hook because I want to make some access checks;

$this->wire()->addHookAfter('Page::viewable', $this, 'checkAccessHook');

– but I get only the default language:

$user->language->name > default

However, I do have the correct user ID and I would have expected that at least using pages->get I can fetch the correct language via a custom lookup?!

$pages->get('id=$user->id, include=all')->language; 

But nope... still just default. Any ideas?

––– 

Alternatively, @ryan if you are listening – I think there is a hook missing to inject access restrictions etc. – somewhere deep down (and early) in the system – that also works for find() operations etc. Most everything is there with PW but this has been a major pain-point for our current project with complicated user access restrictions and configurations. If we could hook into somewhere, that would be amazing. Currently it's really tricky and quickly gets messy when we have user dependecies and with the order if init() and ready() and page::viewable()

Link to comment
Share on other sites

  • 2 weeks later...
  • 7 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...