0

I want to execute my own welcome new user email notification instead of function welcome_user_msg_filter(){} located in ms-functions.php

I recently learned how to override functions in pluggable.php, but the function I am referencing does not have its own if ( ! function_exists( 'welcome_user_msg_filter' ) ) {}.

Has anyone ever overridden a function that lives in ms-functions.php?

If so, how do you go about it?

Thanks

1 Answer 1

1

Functions, which aren't wrapped inside functions_exists() calls, are not meant to be pluggable. If you're searching for extensions, then use filters or hooks - in case there're some.

As you can read in the phpDocBlock:

Ensure that the welcome message is not empty. Currently unused.

So this filter won't work.


I'm no MU expert, but maybe you can make use of the following filter:

apply_filters( 'wpmu_signup_blog_notification_email',
    __( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s" ),
    $domain, $path, $title, $user, $user_email, $key, $meta
)

You'd call it like this:

function wpse56797_signup_blog_notification_email( $message, $domain, $path, $title, $user, $user_email, $key, $meta )
{
    $message = 'Your custom notification';
    return $message;
}
add_filter( 'wpmu_signup_blog_notification_email', 'wpse56797_signup_blog_notification_email', 10, 8 );
7
  • Ok, thanks @kaiser. Do I need to code both your apply_filters() and your function/add_filter() from your example? AND do I make them a custom plugin? Also, I am looking to intercept function welcome_user_msg_filter() so I assume where you have wpse56797_signup_blog_notification_email mine would be welcome_user_msg_filter
    – frank13
    Commented Jun 28, 2012 at 12:06
  • Pleas read my answer - in detail the quote I copied from the phpDocBlock - again. Then go and read through other questions inside the apply_filters to see the difference between "add" and "apply". Then take a look at the ms-functions.php file again and see where the apply_filters comes from.
    – kaiser
    Commented Jun 28, 2012 at 12:12
  • Ok, thanks @kaiser. I did read your answer and I apologize as i am just a stupid person. I am not seeing how your example gets me to overriding function welcome_user_msg_filter(){} located ms-functions.php. I'll plug along though. Appreciate your time.
    – frank13
    Commented Jun 28, 2012 at 12:20
  • The phpDocBlock (in Core code above the function you're referring too), states "Ensure that the welcome message is not empty. Currently unused." . And that means, that the function isn't in use and therefore you can't use it as it won't influence anything. It's like standing in a crowd of people, shouting "PETER", when there's no one named "Peter" and therefore no one will respond.
    – kaiser
    Commented Jun 28, 2012 at 12:37
  • I am too thick on this @kaiser. I don't know how to "ensure that the welcome message is not empty". And does "currently unused" mean that the function is not in use? Because I can tell you that on my install v3.3.2 whenever I add a new user, an email is generated coming from what is inside function welcome_user_msg_filter(){}. All I want to do is intercept that function and run my own.
    – frank13
    Commented Jun 28, 2012 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.