You would hook into profile_update
and user_register
. First check to see if it’s a new user and whether she is an admin/editor.
Then send the mail. Same story with updating the user: see if the role has changed, and whether the new role is admin or editor.
<?php
add_action( 'profile_update', 'wpse33949_profile_update' );
add_action( 'user_register', 'wpse33949_profile_update' );
function wpse33949_profile_update( $user_id, $old_user_data = false )
{
// get the updated user data
$userdata = get_userdata( $user_id );
// whatever you need to send here
$message = "Sign up for my email!";
$subject = "Mailing List";
if( ! $old_user_data && in_array( $userdata->user_role, array( 'editor', 'administrator' ) ) )
{
// we're inserting a new user...
wp_mail( $userdata->user_email, $subject, $message );
}
elseif( in_array( $userdata->user_role, array( 'editor', 'administrator' ) ) && $userdata->user_role != $old_user_data->user_role )
{
// We're updating the role of an existing user, make sure they're
// becoming an admin or editor, then send the message.
wp_mail( $userdata->user_email, $subject, $message );
}
}
The above has not been tested. Copy and paste with caution. Just meant to get you started.