So here’s a simple test function that should send an email (just want to get it working first before I work on other functionality) when a new user is created on the multisite installation. The email should be sent when a user signs up from wp-signup.php and clicks the activation link from their email.
function test_wpmu_new_user( $user_id ) {
wp_mail( 'me@myemail.com', 'The subject', 'The body' );
}
add_action( 'wpmu_new_user', 'test_wpmu_new_user' );
It works from a theme’s functions.php, but not from a simple plugin with nothing else in it.
It also works when I hardcode it into ms-functions.php where another function, newuser_notify_siteadmin
lives, which also fires on wpmu_new_user
. Obviously I don’t want to hardcode it.
And lastly, it does work from the same plugin file, but only when the new user is created by the super admin in the WP admin. I need it to work for a self registering user however. Trac states:
This function runs when a user self-registers as well as when a Super
Admin creates a new user. Hook to ‘wpmu_new_user’ for events that
should affect all new users, but only on Multisite (otherwise use
‘user_register’).
Is it a priority issue? Do I need to load it on a specific hook?