Im trying to add a custom field to WP_USERMETA
table after Woocommerce registration
add_filter('woocommerce_new_customer_data', 'wc_assign_custom_role', 10, 1);
function wc_assign_custom_role($args) {
update_user_meta($user_id, 'user_pass2', password_hash($_POST['password'], PASSWORD_DEFAULT));
return $args;
}
as you see Im trying to capture password before hashing and save it in a different hash format in that table
but It doesnt add anything to the table
I tested the same line inside wordpress registration hook user_register
and it worked but only for wordpress registration not woocommerce
UPDATE
add_filter('woocommerce_new_customer_data', 'wc_assign_custom_role', 10, 1);
function wc_assign_custom_role($args) {
global $current_user;
update_user_meta($current_user->$user_id, 'user_pass2', password_hash($_POST['password'], PASSWORD_DEFAULT));
return $args;
}
still doesnt work
UPDATE II
function action_woocommerce_created_customer( $customer_id, $new_customer_data, $password_generated ) {
update_user_meta($customer_id, 'user_pass2', password_hash($_POST['password'], PASSWORD_DEFAULT));
};
add_action( 'woocommerce_created_customer', 'action_woocommerce_created_customer', 10, 3 );
this one create meta data but it seems it uses different $_POST['password']
rather than the password I entered, so hash something else rather than password
Any thoughts??