What's the right code to send the autoresponder we created to the email of the client that triggered the hook?

一个人想着一个人 提交于 2020-01-16 09:02:42

问题


we are setting up a autoresponder to send to the email of the customer who's order status is changed to completed (were using woocommerce and wordpress and mailster for the autoresponder). The autoresponder and action hook is working properly. The hook triggers the autoresponder to send the email but we can't seem to figure out the code to add so the autoresponder will send the email only to the email of the customer who's order is changed to completed.

We've tried playing with the receivers list provided by the plugin but we can't seem to find the option to put the required condition.

Here's the code we use for the trigger:

function trigger_autoresponder($order_id) {     
    do_action( 'my_custom_hook' );    
}

// add the action 
add_action( 'woocommerce_order_status_completed', 'trigger_autoresponder', 10, 1 );

We expected the autoresponder to send the email to customer's email who triggered the hook only. Your help is much appreciated. Thank you so much in advance.


回答1:


This will do it. I posted an edit on your other question.

function trigger_autoresponder($order_id) {  
    $subscriber_id = mailster_get_current_user_id();
    do_action( 'my_custom_hook', $subscriber_id );    
}

// add the action 
add_action( 'woocommerce_order_status_completed', 'trigger_autoresponder', 10, 1 );


来源:https://stackoverflow.com/questions/58667213/whats-the-right-code-to-send-the-autoresponder-we-created-to-the-email-of-the-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!