我已經安裝了一個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