I would like to automatically assign a random phone number to new user’s phone field when someone register on my wordpress website.
The reason is that I do not want to collect unnecessary data from my customers but my payment gateway requires my customer’s phone number. I personally don’t like to put in my numbers when I buy things and I don’t want that in my website either.
So, if some value is automatically assigned during the sign up and not shown to the users, it would fool my payment gateway.
Tried this in functions.php. Didn’t work.
add_action( 'woocommerce_created_customer','save_phone');
function save_phone($customer_id) {
$phoneno = '000000000';
update_user_meta( $customer_id, 'billing_phone', $phoneno);
}
Can anyone help please?
If your payment gateway requires a phone number, then you must capture a phone number – this is possibly used to validate the payment. Payment providers use postcode and phone number to validate the card information and as an anti fraud measure.