Support » Plugin: WooCommerce » Overriding woocommerce_process_registration() in child theme functions.php

  • Resolved Michael


    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', '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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Okay, I think I solved my own problem.

    The block of code:

    function remove_woocommerce_process_registration() {
    	remove_action('init', 'woocommerce_process_registration')

    Adds an extra layer of exection that’s not needed, and apparently doesn’t quite work right.

    I’ve changed the post-function code to just:

    remove_action('init', 'woocommerce_process_registration' );
    add_action( 'init', 'dalluva_process_registration' );

    That seems to fully disable woocommerce_process_registration().

    I’m not quite sure why it didn’t work properly when the remove_action() call was in remove_woocommerce_process_registration(). Any ideas?

    Meanwhile, I’m back to making progress…


    Thanks for sharing this – was just what we needed!



    Thank you very much for this post! I’m in the quest of adding the “billing_country” select drop-down menu to the registration form, I’ll keep you up with this.


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Overriding woocommerce_process_registration() in child theme functions.php’ is closed to new replies.