Action Hook that fires function upon registration at Woocommerce checkout
-
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)
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.