0

I've been searching around for a solution but am coming up dry. I need to have a confirmation email sent to users when their role is upgraded. By default users are signed up as contributors and make them apply to be upgraded to an author and I want an automated email sent to the user as soon as they are upgraded. Any ideas?

1

Send email notification when user role changes - Adding this snippet to the functions.php of your WordPress theme will send the member an email notification when the user’s role has changed.

function user_role_update( $user_id, $new_role ) {
        $site_url = get_bloginfo('wpurl');
        $user_info = get_userdata( $user_id );
        $to = $user_info->user_email;
        $subject = "Role changed: ".$site_url."";
        $message = "Hello " .$user_info->display_name . " your role has changed on ".$site_url.", congratulations you are now an " . $new_role;
        wp_mail($to, $subject, $message);
}
add_action( 'set_user_role', 'user_role_update', 10, 2);
  • Have you tested this? I put this in my functions.php and tried it and no email was received for account upgraded from contributor to author. – Pollux Khafra May 2 '12 at 16:35
  • I copied and pasted the code from the link above. The author on the linked page, for some reason, uses "fancy" quotation marks (I don't know the proper term) instead of normal. The "fancy" quotation marks do not work in code. I updated them in the snippet above. It should work now. – Travis Pflanz May 2 '12 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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