WordPress の /wp-json/wp/v2/users 対策
事象
WordPressがインストールされているサイトのURLに、/wp-json/wp/v2/users を付与すると、管理者名などが表示されてしまう。
対処
/wp-content/themes/YOUR_THEME/ フォルダ内にある function.php に以下のコードを挿入し、REST API を無効化します。
function disable_rest_api() {
return new WP_Error( ‘disabled’, __( ‘Disable REST API’ ), array( ‘status’ => rest_authorization_required_code() ) );
}
add_filter( ‘rest_authentication_errors’, ‘disable_rest_api’ );