Skip to content

Instantly share code, notes, and snippets.

@justingreerbbi
Created September 8, 2021 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justingreerbbi/720e47f0204d70fa6097e0d6f639df1b to your computer and use it in GitHub Desktop.
Save justingreerbbi/720e47f0204d70fa6097e0d6f639df1b to your computer and use it in GitHub Desktop.
Remove OAuth Access Tokens when a user logs out of WordPress
/**
* Remove all OAuth access tokens when a user logs out of the WordPress
* @param $user_id
*/
function wo_example_destroy_authorizations( $user_id ) {
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 ) );
}
add_action( 'wp_logout', 'wo_example_destroy_authorizations' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment