Here is some code that reads the highest number from the user meta table and then adds +1 to that number. This saves that number for each newly registered user. The code is triggered via the action hook "user_register"
.
add_action( 'user_register', 'assignuserid');
function assignuserid($user_id) {
global $wpdb;
$latestid=$wpdb->get_var("SELECT meta_value from $wpdb->usermeta where meta_key='memnumber' order by meta_value DESC limit 1;");
update_user_meta( $user_id, 'memnumber', $latestid+1 );
}
Note: If the “pay-” is fixed, it does not need to be part of the code that stores the value, only part of the output. i.e:
echo "Your userid: PAY-"+$userid.