Created
October 30, 2018 06:41
-
-
Save pepoipod/e6b9e41bc43a903de4f244a1f9fc00f1 to your computer and use it in GitHub Desktop.
wp-auth0で、auth0のユーザーを削除するコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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