Random User IDs

This WordPress plugin randomizes the user_id for the user created on WordPress setup,
removing one potential attack factor from the site.

Author:David Marín Carreño (DaveFX) (profile at wordpress.org)
WordPress version required:3.1
WordPress version tested:6.4.2
Plugin version:20201115.1
Added to WordPress repository:23-05-2017
Last updated:15-12-2023
Rating, %:80
Rated by:5
Plugin URI:https://davefx.com/random-user-id
Total downloads:4 810
Active installs:400+
plugin download
Click to start download

This WordPress plugin randomizes the user_id for the user created on WordPress setup, removing one potential attack factor from the site.

Since WordPress version 4.9, it also randomizes the ID for all other users created after its setup.
In WordPress versions prior to 4.9, this feature requires installing the patch from WP Issue https://core.trac.wordpress.org/ticket/40545

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.


ChangeLog