PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Send email when role changed manually

s2Member Plugin. A Membership plugin for WordPress®.

Send email when role changed manually

Postby cforant » December 1st, 2011, 9:46 am

Can this system be setup/configured to send an email to the user when i manually change their role to level 1 from a subscriber.



Free version 111105
User avatar
Registered User
Registered User
Posts: 8
Joined: October 25, 2011

Re: Send email when role changed manually

Postby Raam Dev » December 1st, 2011, 9:43 pm

Hi Craig,

If you want to modify the email sent by s2Member when an existing user is being upgraded/downgraded, take a look at this: viewtopic.php?f=4&t=10368&p=33365&hilit=basic+transactional#p33365

If you want to send an email when you manually change the user role, you'll need to modify the behavior of WordPress by adding a function like the following to your theme's functions.php file:

Code: Select all
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);

If you only want to send an email when changing the user role to "Free Subscriber", you'll need to adjust the function code to check $new_role and only proceed with sending the email if it equals "subscriber".
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Posts: 810
Joined: October 26, 2011

Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 1 guest