內容簡介
這個 WordPress 外掛會為 WordPress 安裝時建立的使用者隨機生成 user ID,從而減少網站的一個攻擊因素。
自 WordPress 4.9 版本以來,它也會為安裝後建立的所有其他使用者隨機生成 user ID。
在 WordPress 4.9 版本之前,此功能需要安裝 WP Issue https://core.trac.wordpress.org/ticket/40545 的補丁。
如何運作
啟用後,外掛會立即替換預設管理員使用者(使用者 ID 為 1)的 ID。默認情況下,外掛會使用介於 1 和 4503599627370495 之間的隨機使用者 ID(以確保與使用使用者 ID 的 Javascript 代碼兼容)。
之後建立的所有新使用者將以定義的範圍內的隨機使用者 ID 生成。
如何自訂新使用者 ID 的範圍
您可以使用 WordPress 的篩選器 dfx_random_user_id_max_id 和 dfx_random_user_id_min_id 自訂外掛用於隨機生成使用者 ID 的範圍。
例如,如果您想讓所有使用者 ID 介於 1000 和 9999 之間,您可以將以下行添加到您的主題 functions.php 檔案中:
function set_dfx_max_user_id( $default_max_id ) {
return 9999;
}
add_filter( 'dfx_random_user_id_max_id', 'set_dfx_max_user_id' );
function set_dfx_min_user_id( $default_max_id ) {
return 1000;
}
add_filter( 'dfx_random_user_id_min_id', 'set_dfx_min_user_id' );
也許,您會希望在啟用外掛之前將這些行添加到您的程式碼中,這樣您的新隨機主管理員使用者 ID 就會在您期望的範圍內。
外掛標籤
開發者團隊
原文外掛簡介
This WordPress plugin randomizes the user_id for the user created on WordPress setup, removing one potential attack factor from the site.
How it works
Once activated, the plugin will immediately replace the ID for the default admin user (with user ID 1). By default, the plugin will use random user IDs between 1 and 4503599627370495 (to ensure compatibility with Javascript code using the user ID).
All newly created users from that moment will be generated with a random user ID in the defined range.
How to customize the range for new user IDs
You can customize the range used by the plugin for the random generated user IDs by using the WordPress filters dfx_random_user_id_max_id and dfx_random_user_id_min_id.
For example, if you want to have all your user IDs between 1000 and 9999 you can add the following lines to your theme’s functions.php file:
function set_dfx_max_user_id( $default_max_id ) {
return 9999;
}
add_filter( 'dfx_random_user_id_max_id', 'set_dfx_max_user_id' );
function set_dfx_min_user_id( $default_max_id ) {
return 1000;
}
add_filter( 'dfx_random_user_id_min_id', 'set_dfx_min_user_id' );
Probably, you’ll want to add these lines to your code before activating the plugin, so your new random main admin user ID is inside your desired range.
