I'm creating a SharePoint SPFx web part app.

Using PnPjs I'm able to retrieve the current logged in user's information:

sp.web.currentUser.get().then((response : CurrentUser) => {

        getEmail: response["Email"],


In the currentUser array we have access to the id, title, email address, and etc. If I wanted to add another key to the currentUser array how would I go about doing that.

For example I'm building a shop app. I want to add role column or a preferredMember column to that user. Which I can select decide if the user is a preferred member or not.

The end result I should get something like this in my console.log(response);

odata.type: "SP.User"
odata.id: "hidden for privacy"
odata.editLink: "Web/GetUserById(13)"
Id: 13
IsHiddenInUI: false
LoginName: "i:0#.f|membership|myemail@myemail.com"
Title: "John Smith"
PrincipalType: 1
Email: "myemail@myemail.com"
Role: "Product Tester"
PrefferedMember: "No"

If you're trying to add custom data to users and you want to access that data anywhere a user object is found, I'd suggest you look at schema extensions.

Microsoft has a great example of this.

Guiliano De Luca has a great blog post about that exact topic.

And Office 365 CLI has a cool command that makes it easy for you to add the extension to your schema.

Let me know if you need more sample code to get you started.

I hope this helps?

  • I'm reading over the information you sent me now, thank you! Quick question. Now changing the schema does that affect that user for only that SharePoint site or for that user throughout all of our SharePoint sites? Because I want this change to only be based on this current project. – hisusu32 Apr 15 '20 at 17:04
  • meaning on some SharePoint site's the user might have a different role. So yes I'm looking to add custom data to users. But I want this data to be only defined in this one SharePoint site project. – hisusu32 Apr 15 '20 at 17:19
  • Yes, I understood this to mean adding data to users across projects. You can use the same approach to extend projects/groups/sites, or you could have a list that stores additional user information if you want per project information. – Hugo Bernier Apr 16 '20 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.