leglesslizard
2/22/2018 - 1:04 PM

Email admin when user joins waitlist

An example of how to hook in when a user has been added to the waitlist and email the default admin email address to notify them

add_action( 'wcwl_after_add_user_to_waitlist', 'email_admin_to_notify_of_user_joining_waitlist', 10, 2 );
function email_admin_to_notify_of_user_joining_waitlist( $product_id, $user ) {
  	$admin_email = get_option( 'admin_email' );
  	$product     = wc_get_product( $product_id );
  	if ( $product ) {
    		$subject  = 'A user has just joined a waitlist!';
    		$message  = $user->user_email . ' has just joined the waitlist for ' . $product->get_title();
    		wp_mail( $admin_email, $subject, $message );
  	}
}