I’m trying to get the following function to return an altered username with a number appended. The number should increment by one for each of the identical usernames. I’m calling the wordpress function username_exists() to check for matches. Please help. Thanks
function change_username($name) {
$q = username_exists($name);
$i = 0;
do {
$name = $name . $i++;
} while ($q);
return $name;
}
You cannot “save” the result of the calculation. In addition, you have to keep the fixed part of the name stored separately. Do both by using a
whileloop instead like this: