Skip to content

Commit

Permalink
Adding user ID to getRandomCode() in case other hash parameters are i…
Browse files Browse the repository at this point in the history
…dentical
  • Loading branch information
dparker1005 committed Nov 8, 2024
1 parent f6080b5 commit f92ed9e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions classes/class.memberorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ function saveOrder()
* Get a random code to use as the order code.
*/
function getRandomCode() {
global $wpdb;
global $wpdb, $current_user;

// We mix this with the seed to make sure we get unique codes.
static $count = 0;
Expand All @@ -1589,7 +1589,8 @@ function getRandomCode() {
}

while( empty( $code ) ) {
$scramble = md5( $auth_code . microtime() . $secure_auth_code . $count );
$current_user_id = ! empty( $current_user->ID ) ? $current_user->ID : 0;
$scramble = md5( $auth_code . microtime() . $secure_auth_code . $current_user_id . $count );
$code = substr( $scramble, 0, 10 );
$code = apply_filters( 'pmpro_random_code', $code, $this ); //filter
$check = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->pmpro_membership_orders WHERE code = %s LIMIT 1", $code ) );
Expand Down

0 comments on commit f92ed9e

Please sign in to comment.