XF 2.0 How to detect if a user ($user) is Super Moderator?

Scandal

Well-known member
Well, for admin we have $user->is_admin
For super admin we have $user->is_super_admin
There is also the general $user->is_moderator

Is there any similar way to determine if a $user is Super Moderator? :)
Or any suggestion how to detect it with no extra queries?
 
I don't believe there is any way to do this in the core. You could add a relation between the User entity and the Moderator entity, and then use $user->Moderator->is_super_moderator, but this will incur an additional query unless you can eager-load the Moderator relation everywhere you need it.

It's worth noting that is_super_admin works the same way (it will incur an additional query unless the Admin relation is eager-loaded), though it uses a getter that first checks the is_admin column, which will mitigate this somewhat.
 
Thanks Jeremy, I used a relation via the Finder so it is doing just a mysql join, so no extra query :)
 
I think it is easier if you assign all super moderator to a unique usergroup (secondary usergroup), and you can check if a user is member of that usergroup :)
 
Back
Top Bottom