• Resolved King Ding

    (@dazzerr)


    I’ve created a function that sends a message in BuddyPress to the current user after checking out with a Woocommerce product. However, this only works if the user already has an account prior to checking out. However, users of my website cannot create an account prior to checkout, they must create their account at the checkout.

    I’ve tried hooks such as:

        user_register
        register_new_user
        woocommerce_order_status_completed

    But none of them have worked for me. Might someone be able to example why, and leave an alternative suggestion?

    Here is my code. Thanks!

    function send_message_to_new_member( $user_id) {
        		
                $current_user = get_current_user_id();
                $current_user_name = wp_get_current_user();
            
                $args = array(
                    'sender_id' => 1,
                    'thread_id' => false,
                    'recipients' => $current_user,
                    'subject' => 'Welcome!',
                    'content' => sprintf( __( 'Hey %1$s, here is my message' ), $current_user_name->user_firstname ),
                    'date_sent' => bp_core_current_time()
                );
        
                $result = messages_new_message( $args );
        }
        add_action( 'woocommerce_order_status_completed', 'send_message_to_new_member', 2 );
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi @dazzerr ??

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Thread Starter King Ding

    (@dazzerr)

    Oh yeah? Complex in that, an action hook won’t cut it? Hopefully someone can provide some insight – thanks for the suggestions!

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hopefully, a developer will chime in and help you out! ??

    Cheers!

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers!

    @dazzerr Hey,

    Did you ever find a solution to this? I have the exact same issue, in that I need to update user meta after account creation, but before the purchase is completed.

    Mirko P.

    (@rainfallnixfig)

    Hi @w4yp01nt,

    Please create your own thread for your issue. We want to make sure that every user’s issues receive their own thread with proper attention.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Action Hook that fires function upon registration at Woocommerce checkout’ is closed to new replies.