Skip to content

Instantly share code, notes, and snippets.

@justingreerbbi
Created October 24, 2015 21:53
Show Gist options
  • Save justingreerbbi/241ceb400b66606283da to your computer and use it in GitHub Desktop.
Save justingreerbbi/241ceb400b66606283da to your computer and use it in GitHub Desktop.
Only allow 1 access token session per client
/**
* Only allow 1 acces_token at a time
* @param [type] $results [description]
* @return [type] [description]
*/
function test_only_allow_one_access_token ( $object ) {
if ( is_null( $object ) )
return;
// Define the user ID
$user_id = $object['user_id'];
// Remove all other access tokens and refresh tokens from the system
global $wpdb;
$wpdb->delete( "{$wpdb->prefix}oauth_access_tokens", array( "user_id" => $user_id ) );
$wpdb->delete( "{$wpdb->prefix}oauth_refresh_tokens", array( "user_id" => $user_id) );
return;
}
add_action('wo_set_access_token', 'test_only_allow_one_access_token');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment