我有一个使用此功能发送电子邮件的插件
function em_event_added_email($EM_Event){
if( !$EM_Event->get_status() && get_option('dbem_bookings_approval') && get_option('dbem_event_submitted_email_admin') != '' ){
$admin_emails = explode(',', get_option('dbem_event_submitted_email_admin')); //admin emails are in an array, single or multiple
$subject = $EM_Event->output(get_option('dbem_event_submitted_email_subject'));
$message = $EM_Event->output(get_option('dbem_event_submitted_email_body'));
//Send email to admins
$EM_Event->email_send( $subject,$message, $admin_emails);
}
}
add_action('em_event_added','em_event_added_email', 10, 1);
我希望能够从主题functions.php替换此函数,以便我可以自定义$message
输出,目的是将HTML数据添加到此插件发送的所有电子邮件的页脚中,因此如果有除了替换功能以外,其他方式会更好
答案 0 :(得分:0)
插件有这个功能吗?如果插件没有过滤器(在插件中查找apply_filters),则可以通过删除原始钩子来替换它:
remove_action('em_event_added','em_event_added_email', 10, 1);
然后在主题的php(函数或包含)中创建自己的函数,并用自己的函数替换函数名称,并将其重新放在具有相同优先级的同一个钩子中。
function yourprefix_new_em_event_added_email($EM_Event){
if( !$EM_Event->get_status() && get_option('dbem_bookings_approval') && get_option('dbem_event_submitted_email_admin') != '' ){
$admin_emails = explode(',', get_option('dbem_event_submitted_email_admin')); //admin emails are in an array, single or multiple
$subject = $EM_Event->output(get_option('dbem_event_submitted_email_subject'));
$message = $EM_Event->output(get_option('dbem_event_submitted_email_body'));
//Send email to admins
$EM_Event->email_send( $subject,$message, $admin_emails);
}
}
add_action('em_event_added','yourprefix_new_em_event_added_email', 10, 1);