WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Overriding woocommerce_process_registration() in child theme functions.php (4 posts)

  1. Michael
    Member
    Posted 1 year ago #

    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

    http://wordpress.org/extend/plugins/woocommerce/

  2. Michael
    Member
    Posted 1 year ago #

    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
    Michael

  3. redearthdesign
    Member
    Posted 10 months ago #

    Thanks for sharing this - was just what we needed!

  4. maehdros
    Member
    Posted 9 months ago #

    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.

    Cheers!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic