Forum

Thread tagged as: Question, Add-on-development

Get logged in admin data

Hello,

I was wondering whether it's possible to get the current Perch logged in user data with the API?

Use case: I have created my own app, and part of it you can send email reports and there is a select box where you choose who you want it sent to. One of which I want to be "Me" which sends to logged in Perch user.

Hopefully this makes sense.

Dexter Harrison

Dexter Harrison 29 points

  • 5 years ago

Dexter. In your app you need to include the PerchMembers_Session class, then you can get the $Session object which contains all the information about the logged in user. I think I may have an exact example of this code on my office computer. Let me know if I need to dig it up for you.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you wanting to do this within the control panel or out on your site?

Hi Drew,

It would be in the control panel

Drew McLellan

Drew McLellan 2638 points
Perch Support

In which case you probably have $CurrentUser in scope.

$CurrentUser->userEmail()

Perfect!

Thanks Drew

Dexter, sorry but I was totally not thinking when I responded... My response was for member details, not admin... Oops. :(

Drew McLellan said:

In which case you probably have $CurrentUser in scope.

$CurrentUser->userEmail()