Check user permissions by user id

Discussion forum for Extension Writers regarding Extension Development.
User avatar
danieltj
Jr. Extension Validator
Posts: 344
Joined: Thu May 03, 2018 9:32 pm
Location: United Kingdom
Name: Daniel James

Check user permissions by user id

Post by danieltj »

Is there a way to check a users permissions when it's not the currently authenticated user? I'm aware that I can do the following:

Code: Select all

$this->acl_get( 'u_hide_verified_badge' )
But this checks the currently authenticated user. I want to check a different user by ID and I'm not entirely sure if this is possible. I've checked the documentation but it only mentions passing a forum ID to the acl_get function.

I'm sure this is possible. I just don't know how to do it ;)
Available for paid extensions development; hire me!
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3789
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: Check user permissions by user id

Post by Kailey »

You'll need a user array of some sort. In the example below, $row is our user array.

Code: Select all

$auth2 = new \phpbb\auth\auth();
$auth2->acl($row);
$s_in_group = $auth2->acl_get('some_permission') ? true : false;
unset($auth2);
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders
User avatar
danieltj
Jr. Extension Validator
Posts: 344
Joined: Thu May 03, 2018 9:32 pm
Location: United Kingdom
Name: Daniel James

Re: Check user permissions by user id

Post by danieltj »

Exactly what I needed, thank you :)
Available for paid extensions development; hire me!

Return to “Extension Writers Discussion”