User profile sync between wordpress and auth0 without logout

Please include the following information in your post:

  • Which SDK this is regarding: Login by Auth0 wordpress plugin
  • SDK Version: 4.3.1
  • Platform Version: wordpress 5.9.3

The problem:

We’re using app_metadata to store user subscription information, one scenario is user from wordpress page buy subscripiton and updated the auth0 app_metadata by a thirdparty AWS lambda function. the app_metadata got update on auth0(checked by auth0 dashboard). but the data inside wordpress database is not updated(get_currentauth0user()->auth0_obj->app_metadata).

I know kick user out and let user login back can solve this issue but that’s obviously not a good experience. Also I checked the sourcecode and almost all the github issues there is no way to sync between auth0 and wordpress manually(some magic method like sync_auth0_profile or something).

Anyone know how to archive this? I think it’s a very common scenario you want a way to get latest user metadata for wordpress.


Hi @tech16 :wave:

We don’t currently support this type of feature. The database updates occur during login because this is where and when the profile data for the user is pulled, during the authentication flow. It’s embedded as part of the JSON web token that’s exchanged during authentication.

In order to support this type of sync outside the authentication flow, and on demand as you suggested, you’d need to make Management API calls to query an individual user by id and retrieve their profile data, then apply the changes yourself to the database. This could be rather complex to achieve, in particular because you’d need to keep API rate limiting in mind if you’re going to be performing this across many users, or very often.

Here’s a link the Management API reference document on GET /user/:id endpoint you’d need to work with Auth0 Management API v2

Looking forward, the next version of the WordPress plugin will be using our PHP SDK to power all the API calls. You could consider writing something custom against that SDK to achieve what you’re looking to do more easily than writing custom HTTP calls youself. There’s an example of Management API usage with that SDK in the QuickStart: auth0-php-web-app/Management.php at main · auth0-samples/auth0-php-web-app · GitHub

1 Like