Skip to content

Instantly share code, notes, and snippets.

@pepoipod
Created October 30, 2018 06:41
Show Gist options
  • Save pepoipod/e6b9e41bc43a903de4f244a1f9fc00f1 to your computer and use it in GitHub Desktop.
Save pepoipod/e6b9e41bc43a903de4f244a1f9fc00f1 to your computer and use it in GitHub Desktop.
wp-auth0で、auth0のユーザーを削除するコード
<?php
global $wpdb;
$current_user = wp_get_current_user();
$user_id = $current_user -> ID;
$auth0_id = get_user_meta($user_id, $wpdb -> prefix . 'auth0_id', true);
$serialized_profile = get_user_meta($user_id, $wpdb -> prefix . 'auth0_obj', true);
$user_info = empty($serialized_profile) ? false : WP_Auth0_Serializer ::unserialize($serialized_profile);
var_dump($auth0_id);
var_dump($user_info);
$a0_options = WP_Auth0_Options ::Instance();
var_dump($a0_options);
$domain = $a0_options -> get('domain');
$app_token = $a0_options -> get('auth0_app_token');
$parts = explode( '.', $app_token );
$payload = json_decode( JWT::urlsafeB64Decode( $parts[1] ) );
var_dump($payload);
$endpoint = "https://$domain/api/v2/users/$auth0_id";
$header = WP_Auth0_Api_Client ::get_info_headers();
$headers['Authorization'] = "Bearer $app_token";
$headers['content-type'] = 'application/json';
$response = wp_remote_post(
$endpoint, array(
'method' => 'DELETE',
'headers' => $headers,
)
);
var_dump($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment