
內容簡介
**總結:** 這個外掛修改了 /wp-json/wp/v2/users 端點,需要用戶驗證。如果直接訪問此端點,會收到 401 未經授權的回應。然而,透過瀏覽器控制台運行 wp.apiFetch() 函數,可以獲取用戶列表。
1. 這個外掛對哪個 WordPress API 端點進行了修改?
- 答:/wp-json/wp/v2/users
2. 在 WordPress 網站上,默認情況下如何查看已發佈內容的用戶列表?
- 答:透過訪問 /wp-json/wp/v2/users 端點
3. 什麼情況下這個外掛會要求用戶進行身份驗證?
- 答:瀏覽用戶列表時必須通過身份驗證
4. 如果直接訪問 /wp-json/wp/v2/users 端點,會收到什麼回應?
- 答:401 未經授權的回應
5. 透過哪個函數可以獲取用戶列表?
- 答:wp.apiFetch({path: 'wp/v2/users'})
6. 這個外掛的作者是誰?
- 答:Sal Ferrarello / salferrarello.com
外掛標籤
開發者團隊
② 後台搜尋「Require Auth Users REST Endpoint」→ 直接安裝(推薦)
原文外掛簡介
This plugin modifies the /wp-json/wp/v2/users endpoint to require authentication.
By default on a WordPress site you can list the users that have posted content on the site by visiting this endpoint.
This plugin requires the user to be authenticated to view the list of users.
What this means
If you go directly to the URL /wp-json/wp/v2/users you will get a 401 Unauthorized response.
But if you open a block editor page and run the following from the browser console,
await wp.apiFetch({path: 'wp/v2/users'});
you will get a list of users (because the wp.apiFetch() function authenticates the user’s call to the WordPress REST API).
Author
Sal Ferrarello / salferrarello.com
