Reputation: 12568
I am trying to modify the function for wc_create_new_customer in Woocommerce, I have added this to my functions.php file...
remove_action( 'init', 'wc_create_new_customer');
add_action('init', 'wc_create_new_customer');
function wc_create_new_customer( $email, $username = '', $password = '' ) {
// My custom function
}
This is obviously giving me an error as wc_create_new_customer has already been delcared. How can I modify this to work?
Upvotes: 1
Views: 570
Reputation: 33
Id like to know a fix for this, trying to change the standard user role from customer to a custom one. this seems the only way I can change it.
However the "fix" above is no good as it dont take the new function.
Upvotes: 2
Reputation: 1943
Change the name of your customised wc_create_new_customer
(to my_wc_create_new_customer
or similar) and use that in your call to add_action
.
Update:
Rather than modifying a core function, you want to use an action to make a custom function run at a certain when a certain event occurs. The woocommerce_created_customer
event is triggered by WooCommerce when a new customer is created, so you can hook into that action to make your code run:
add_action('woocommerce_created_customer', 'do_things_on_customer_create', 10, 3);
function do_things_on_customer_create($customer_id, $customer_data, $password_generated) {
// My custom function
}
Upvotes: 0