Title: Return user meta value
Last modified: June 1, 2021

---

# Return user meta value

 *  [mattrin](https://wordpress.org/support/users/mattrin/)
 * (@mattrin)
 * [5 years ago](https://wordpress.org/support/topic/return-user-meta-value/)
 * Hi I have looked at you guidance at:
 * [https://wp-oauth.com/docs/how-to/extending-endpoints/](https://wp-oauth.com/docs/how-to/extending-endpoints/)
 * $me_data = apply_filters(‘wo_me_resource_return’, $me_data, $token);
 * I need to return some of the additioal fields stored against the user in the 
   user end point. I am able to add these field to the rest API suing below – kindly
   advise how ca i reflect this in the oauth end point being returned through json
   token.
 * register_meta( ‘user’, ‘meta_key_here’, [ ‘show_in_rest’ => true ] );
 *     ```
       add_action( 'rest_api_init', 'adding_user_meta_rest' );
           function adding_user_meta_rest() {
              register_rest_field( 'user',
                                   'collapsed_widgets',
                                    array(
                                      'get_callback'      => 'user_meta_callback',
                                      'update_callback'   => null,
                                      'schema'            => null,
                                       )
                                 );
           }
          function user_meta_callback( $user, $field_name, $request) {
              return get_user_meta( $user[ 'id' ], $field_name, true );
          }
       ```
   

The topic ‘Return user meta value’ is closed to new replies.

 * ![](https://ps.w.org/oauth2-provider/assets/icon-256x256.gif?rev=2603051)
 * [WP OAuth Server (OAuth Authentication)](https://wordpress.org/plugins/oauth2-provider/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/oauth2-provider/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/oauth2-provider/)
 * [Active Topics](https://wordpress.org/support/plugin/oauth2-provider/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/oauth2-provider/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/oauth2-provider/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [mattrin](https://wordpress.org/support/users/mattrin/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/return-user-meta-value/)
 * Status: not resolved