Change the phone number
Here you will learn, how to change the phone number.
First steps
First, we have to initialize the class and set the user id.
use ZitadelPhpClient\User\Phone;
$phone = new Phone($settings);
$phone->setUserId("12345678");
Change the phone number
Run this function:
$phone->changeEmail("someone@example.com");
IMPORTANT: The phone number is not verified. The API returns a verification code, which you can get with this function:
$phone->getVerificationCode();
Get a new verification code
Run this function:
$phone->resendVerificationCode();
After that, you can get the verification code with
$phone->getVerificationCode();
Verify the phone number
To verify the phone number run:
if ($phone->isVerified("123456")) {
echo "Phone verified";
} else {
echo "Verification failed";
}
The function returns true or false.
Last modified: 27 March 2024