I want to automatically generate username from the name field.
Then check if the username already exists.
If username exists it is supposed to add a number at the end (ascending and not random).
How do i change the code to a while loop?
For checking if the username exists i would use username_exists()
Can someone help me with this?
Thanks
function custom_validate_user_signup($result){
unset($result['errors']->errors['user_name']); if(!empty($_POST['field_1'] )) { $result['user_name'] = $_POST['field_1'] .'_'. rand(1, 9999); $_POST['signup_username'] = $result['user_name']; $result['user'] = $_POST['field_1']; $_POST['signup_password_confirm']=$_POST['signup_password']; } return $result; }