我已经安装了一个WordPress的插件(资料创建),其中包括该指令用于过滤函数替换WordPress的插件功能:使用过滤器
Filter 'wppb_signup_user_notification_filter' to bypass this function or
replace it with your own notification behavior.
事实上,我想替换随后用我自己的这个指令的功能它改变了正在发送的电子邮件的文本。原有的功能开始时是这样的:
function wppb_signup_user_notification($user, $user_email, $activation_key, $meta = '') {
if (!apply_filters('wppb_signup_user_notification_filter', $user, $user_email, $activation_key, $meta))
return false;
...
}
我复制该功能在我自己的插件,并更名为:
function cvc_signup_user_notification($user, $user_email, $activation_key, $meta = '') {
...(NOTE: I left out the if(!apply_filters conditional as it caused a server 500 error)
}
我现在有这个过程的remove_filter和部分的add_filter难度。我已经试过:
remove_filter( 'wppb_signup_user_notification_filter', 'wppd_signup_user_notification');
add_filter( 'wppb_signup_user_notification_filter', 'cvc_signup_user_notification');
有了这样的结果:
Warning: Missing argument 2 for cvc_signup_user_notification() in /home/ccarlv5/public_html/homebaseinc/wp-content/plugins/cvc-profile-builder-homebase-emails/index.php on line 306
Warning: Missing argument 3 for cvc_signup_user_notification() in /home/ccarlv5/public_html/homebaseinc/wp-content/plugins/cvc-profile-builder-homebase-emails/index.php on line 306
而且这样的尝试:
remove_filter( 'wppb_signup_user_notification_filter', 'wppd_signup_user_notification',$user, $user_email, $activation_key, $meta);
add_filter( 'wppb_signup_user_notification_filter', 'cvc_signup_user_notification',$user, $user_email, $activation_key, $meta);
产生以下结果:
Warning: Missing argument 1 for cvc_signup_user_notification() in /home/ccarlv5/public_html/homebaseinc/wp-content/plugins/cvc-profile-builder-homebase-emails/index.php on line 306
Warning: Missing argument 2 for cvc_signup_user_notification() in /home/ccarlv5/public_html/homebaseinc/wp-content/plugins/cvc-profile-builder-homebase-emails/index.php on line 306
Warning: Missing argument 3 for cvc_signup_user_notification() in /home/ccarlv5/public_html/homebaseinc/wp-content/plugins/cvc-profile-builder-homebase-emails/index.php on line 306
我试着加入过滤器没有删除原来的,哪个r在相同的3个错误esults(和原来的功能仍然能够被使用)
有人点我在正确的方向实现我自己的改良电子邮件通知替换原有功能的目标。
任何指导,将不胜感激。 谢谢。
没有改变我找到了答案。我需要明确指定add_filter的参数优先级和数量:'add_filter('wppb_signup_user_notification_filter','cvc_signup_user_notification',10,4);' – cvc 2015-02-12 12:55:47
我说得太快了。虽然我的新功能正在工作,没有缺少参数错误发生,而我得到我的自定义文本的电子邮件,我也从原来的功能接收重复的电子邮件。所以remove_filter行不起作用。建议? – cvc 2015-02-12 13:14:51