Displaying user_metadata in Wordpress

I am having trouble accessing the user_metadata information in WordPress. I am currently using the Auth0 plugin.

I have a bare-bones application and I would like to see the user’s first name and last name in the application. I added the two additional fields to additionalSignUpFields configuration option as shown below.

{
  "additionalSignUpFields": [
    {
      "name": "first_name",
      "placeholder": "Please enter your first name"
    },
    {
      "name": "last_name",
      "placeholder": "Please enter your last name"
    }
  ]
}

This works great. New users can add the additional metadata to their profiles via the signup form. However, I am having trouble accessing the user’s first name and last name within the WordPress application.

I stumbled upon Custom fields with wordpress? - #2 by kimcodes and it is mentioned that this data should be attached to the wp_auth0_obj in WordPress.

Here is a code snippet I am using to access the wp_auth0_obj.

<?php
     $user_id = get_current_user_id(); 
     $key = 'wp_auth0_obj'; 
     $single = true; 
     $auth0_user = get_user_meta( $user_id, $key, $single ); 
     print_r($auth0_user); 
?>

This results in printing a similar object to this (values have been changed and removed for privacy):

{
  "created_at": "2021-02-19T19:10:36.216Z",
  "email": "test@test.com",
  "email_verified": true,
  "identities": [
    {
      "user_id": "",
      "provider": "auth0",
      "connection": "",
      "isSocial": false
    }
  ],
  "name": "test@test.com",
  "nickname": "",
  "picture": "",
  "updated_at": "2021-02-22T21:54:25.377Z",
  "user_id": "",
  "last_ip": "",
  "last_login": "2021-02-22T21:54:25.377Z",
  "logins_count": 14,
  "sub": ""
}

I do not see a user_metadata property object.
Should I be seeing it?
How can I get access to the user_metadata in WordPress?

I appreciate your help!

Apologies. I needed to log in and out again to get the updated data. Sorry about that!

seangolob, I am a complete noob to auth0 and am looking to display auth0 user meta data in wordpress.

I see you are using ‘wp_auth0_obj’ to get the data, but I’m confused on how to parse that out to display just a specific item. For example within my user meta data I have a ‘family_name’ that equals the user’s last name. How can I get wordpress/PHP to echo jus the family_name value under the ‘wp_auth0_obj’?

Any help would be appreciated. Thank you.

1 Like

Bonjour, I’m also using a Wordpress + Auth0 configuration. I would like to display a single user_metadata in a column ? How can i use ‘wp_auth0_obj’ for this ?
Thank you,