How do I access user’s picture within a hook?

const Chatkit = require('@pusher/chatkit-server')

const chatkit = new Chatkit.default({
  instanceLocator: 'v1:us1:6759a97c-d77e-4a06-89f4-3df55679df5e',
  key: 'KEY',
})

module.exports = function (user, context, cb) {

  chatkit
    .createUser({
      id: `auth0|${user.id}`,
      name: user.email,
      avatarURL: user.picture // <<<<< HOW DO I ACCESS PICTURE?
    })
    .then(() => cb())
    .catch((err) => {
      console.log(err)
      cb(err)
    });
}

From within a Post User Registration hook I would like to access my user’s picture. However user.picture is undefined.

I tried adding picture to user_metadata in a rule but then I realised I cannot access user_metadata from the hook either :open_mouth:

What should I do?

Is it okay to bump this? Still not figured it out!

This may not be the exact answer your are looking for, but why can’t you just use a rule - you can definitely access the picture there, and it may be a better solution since as the picture changes, you will be able to keep it updated.

As you can see, the picture is easily accessible via a rule using the user.picture property

image

Also, the rule will fire when the user first signs up.

Sahil

Thank you for your answer @sahil.malik and sorry for the slow response.

Unfortunately, I never did figure this out and have since moved on to another project. Going to leave this as “unsolved” in case anyone else encounters the same problem.

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?