Add email addresses to already registered users
Question
my website users register with phone number OTP. That’s why they have no email address in their accounts. Today I need email address in user accounts. I use this code to add email address for new user registrations.
add_action("user_register", function ($user_id) {
$user = get_userdata($user_id);
if (empty($user->data->user_email)) {
$args = array(
"ID" => $user->id,
"user_email" => uniqid() . "@example.com",
);
wp_update_user( $args );
}
});
add_filter( 'bnfw_trigger_insert_post', '__return_true' );
But I have about 3000 users that need email address in their accounts and above code generate email like this 62961a20c7f2a@exmaple.com (how can use “username” instead of uniqid() . How can I do this automatically . Can make above code to work for already registered user.
0
8 months
2022-05-31T08:17:01-05:00
2022-05-31T08:17:01-05:00 0 Answers
0 views
0
Leave an answer