Overriding woocommerce_process_registration() in child theme functions.php
-
Hello Forum:
I’m trying to customize the new user registration function included in woocommerce, and of course I’m trying to avoid direct editing of the plugin file woocommerce-functions.php by using a child theme with it’s own functions.php.
The woocommerce function woocommerce_process_registration() resides in woocommerce-functions.php and is hooked in within woocommerce-hooks.php with the following line:
add_action( 'init', 'woocommerce_process_registration' );
In my function.php, I’ve created a new registration processing function called my_process_registration().
After that function declaration in functions.php, I have added the following lines to remove the woocommerce_process_registration() function and add in my_process_registration instead:
function remove_woocommerce_process_registration() { remove_action('init', 'woocommerce_process_registration') } add_action('init','remove_woocommerce_process_registration'); add_action( 'init', 'my_process_registration' );
Okay, by putting in some debugging cide, I have verified that the remove_action(‘init’, ‘woocommerce_process_registration’) is executing successfully (it returns TRUE).
The add_action( ‘init’, ‘my_process_registration’ ) is also executing fine.
For the registration form, I’m using the standard woocommerce login/registration form in the woocommerce my-account page.
The problem is, when the registration form on the my-account page is executed (click on Register button), BOTH the woocommerce_process_registration() and my_process_registration() are executing sequentially (the woocommerce version first, then my version). I thought that the remove_action() call would disable woocommerce_process_registration(), but it doesn’t appear to be doing so.
Any pointers on why the function keeps executing even after the remove_action() call? I must be missing something here.
Many thanks
Michael
- The topic ‘Overriding woocommerce_process_registration() in child theme functions.php’ is closed to new replies.