Skip to content

Commit 2ff073e

Browse files
committed
Adding dfx_random_user_id_get_min_id filter
1 parent 6a2bc9d commit 2ff073e

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

dfx-random-user-id.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Random User IDs
44
Plugin URI: https://davefx.com/random-user-id
55
Description: Sets random user IDs for created users. Randomizes the user ID for the default user, if it exists.
6-
Version: 20190125
6+
Version: 20201115
77
Author: David Marín Carreño (DaveFX)
88
Author URI: https://davefx.com
99
License: GPL3
@@ -25,6 +25,17 @@ function dfx_random_user_id_get_max_id() {
2525
}
2626
}
2727

28+
if ( ! function_exists( 'dfx_random_user_id_get_min_id' ) ) {
29+
30+
function dfx_random_user_id_get_min_id() {
31+
32+
// Javascript MAX_SAFE_INTEGER = 9007199254740991
33+
// so we define the maximum ID to be one bit shorter
34+
35+
return apply_filters( 'dfx_random_user_id_min_id', 1 );
36+
}
37+
}
38+
2839
if ( ! function_exists( 'dfx_random_user_id_user_register' ) ) {
2940

3041
/**
@@ -41,7 +52,7 @@ function dfx_random_user_id_user_register( $data, $update ) {
4152

4253
// Locate a yet-unused user_id
4354
do {
44-
$ID = random_int( 1, dfx_random_user_id_get_max_id() );
55+
$ID = random_int( dfx_random_user_id_get_min_id(), dfx_random_user_id_get_max_id() );
4556
} while ( get_userdata( $ID ) );
4657

4758
$data += compact( 'ID' );

readme.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Contributors: DaveFX
33
Donate link: https://paypal.me/davefx
44
Tags: security, user ids
55
Requires at least: 3.1
6-
Tested up to: 5.2.4
7-
Stable tag: 20190125
6+
Tested up to: 5.6.0
7+
Stable tag: 20201115
88
License: GPLv3
99
License URI: http://www.gnu.org/licenses/gpl-3.0.html
1010

@@ -15,6 +15,10 @@ In WordPress versions prior to 4.9, this feature requires installing the patch f
1515

1616
== Changelog ==
1717

18+
= 20201115 =
19+
20+
* Adding new filter dfx_random_user_id_min_id to customize the minimum allowed user ID number
21+
1822
= 20190125 =
1923

2024
* Adding new filter dfx_random_user_id_max_id to customize the maximum allowed user ID number

0 commit comments

Comments
 (0)