Screenshot COVID-19 Update We have changed are structure to better support our employees and customers through these hard times.
See Updates

Extending Endpoints

Published: October 4, 2018 | Updated: January 27th, 2020
  1. Home
  2. Docs
  3. How To
  4. Extending Endpoints

At some point, you may need to change the data provided by WP OAuth Server’s resource endpoints. Data can be modified by using a filter.

The filter that contains the endpoints and callbacks used is wo_endpoints.


The following code can be placed in your theme’s functions file or a custom plugin to modify the user endpoint (oauth/me) and the data that is returned.

add_filter('wo_endpoints','wo_extend_resource_api', 2);
function wo_extend_resource_api ($methods){
 $methods['me'] = array('func'=>'_wo_me_1');
 return $methods;

* Replaces the default me enpoint
* @param [type] $token [description]
* @return [type] [description]
function _wo_me_1 ( $token=null ){
 $user_id = &$token['user_id'];

 global $wpdb;
 $me_data = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}users WHERE ID=$user_id", ARRAY_A);

 /** prevent sensative data - makes me happy ;) */
 unset( $me_data['user_pass'] );
 unset( $me_data['user_activation_key'] );
 unset( $me_data['user_url'] );
 unset( $me_data['session_tokens'] );

 // add user metadata
 $infometa = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->prefix}usermeta WHERE user_id = ".$user_id."");
 foreach ($infometa as $metarow) {

 $key = $metarow->meta_key;
 if( is_serialized( $metarow->meta_value ) ){
 $me_data[$key] = unserialize( $metarow->meta_value );
 $me_data[$key] = $metarow->meta_value;

 $response = new WPOAuth2\Response($me_data);