• Hi,

    If I update a user role from Editor to Subscriber in the user panel, does the user get an email notification of this? Or will they just notice the difference after loggin in?

    TIA

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    I’m pretty sure (99.44%) that they will not get an email notification and will only see the difference when they login.

    adispiac

    (@adispiac)

    You can make it 100% ??

    A simple way to email your users when changin their role is by adding this code to your active theme’s functions.php file or in an empty plugin like this one.

    function email_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;
    
        if ( strtotime ( $user_info->user_registered) < strtotime ('-30 minutes') ) {
            wp_mail($to, $subject, $message);
        }
    }
    add_action( 'set_user_role', 'email_user_role_update', 10, 2);

    Hope this helps!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Update user notifications’ is closed to new replies.