latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Customized e-mail when manual level change

Home Forums Community Forum Customized e-mail when manual level change

This topic contains 8 replies, has 2 voices. Last updated by  Raam Dev 4 years, 4 months ago.

Topic Author Topic
Posted: Saturday Aug 11th, 2012 at 3:59 pm #21786
Nordin Chena
Username: Nordino

Hi

I have a few things I’d like to edit before launching the new s2member plugin on my site.

1) I would like a customized e-mail to be sent out every time I upgrade a user. Many users pay the membership fee by bank transaction and therefore I have to upgrade the level manually. Right now the user has no idea that he is upgraded unless I manually send emails to all users.

I am talking about users that have level 0 (non-paying members) and that I upgrade to level 1 (paying member). I dont use any other levels.

How can this be done?

2) Where do I translate login page, registration page, profile fields etc.?

List Of Topic Replies

Viewing 8 replies - 1 through 8 (of 8 total)
Author Replies
Author Replies
Posted: Saturday Aug 11th, 2012 at 11:52 pm #21801
Raam Dev
Username: Raam
Staff Member

Hi Nordin,

For sending an email when the role is changed manually, please see this thread.

For translations, please see Pre Sale FAQs » Can s2Member® be translated into other languages? and also this thread.

Posted: Monday Aug 13th, 2012 at 2:40 am #21856
Nordin Chena
Username: Nordino

Thank you for your help, Raam.

Unfortunately I cannot get any of the issues to work. I am probably doing something wrong even though I try my best to stick to the instructions.

Where in theme/funcions.php do I insert the code? I tried to put it on top, in the middle and in the bottom, but in all cases I got an error message or blank page whenever I do something in wp-admin. Restored to the original functions.php and it worked fine again.

Regarding the translation, I downloaded poedit and translated. Saved a .mo file that I uploaded to wp-content/plugins. But the text remains in English :S Any suggestions to what I am doing wrong?

Posted: Tuesday Aug 14th, 2012 at 12:10 am #21947
Nordin Chena
Username: Nordino

The auto-mail when manual level change code you provided actually worked now, but what happens is that everything in admin panel get a blank page.

Maybe there is a specific place in funcions.php I need to put this code?

Posted: Tuesday Aug 14th, 2012 at 10:00 am #21993
Raam Dev
Username: Raam
Staff Member

Hi Nordin,

The code should go at the bottom, before the ?> tag. Also, there should be no spaces after that ?> tag. If that still doesn’t fix it, you may want to enable WordPress debugging to see if you can see some error messages instead of the white page

Regarding translations: Have you tried this plugin instead of POEdit? Also, have you read this article and this one?

Posted: Tuesday Aug 14th, 2012 at 1:40 pm #22015
Nordin Chena
Username: Nordino

Thanks Raam, it worked now when I put the code in the bottom but before the last tag.

I managed to configure it somewhat, but I dont know much about php so I didnt get the e-mail how I wanted.

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 = "Ditt medlemsskap i TAN er nå aktivert!";
        $message = "Hei " .$user_info->display_name . " , din bruker på ".$site_url." er nå oppgradert til " . $new_role;
        wp_mail($to, $subject, $message);
}
add_action( 'set_user_role', 'user_role_update', 10, 2);

I would like the email to look like this:

Topic: Ditt medlemsskap i TAN er nå aktivert! (fine as it is)

Hei <user>, din bruker på NewUtd.no er nå blitt oppgradert til medlem.
<p>
Du kan nå logge inn på medlemssiden og lese medlemsblader, laste ned høydepunkter, delta i konkurranser og så videre.
<p>
Medlemspakken med det første medlemsbladet, plakat og medlemskort blir sendt ut i september. De to andre bladene blir gitt ut i desember og mai.
<p>
Her er ditt brukernavn og passord til innlogging:
<Username>
<Password>
<p>
Med vennlig hilsen
NewUtd-teamet

Do you know how I can fix the e-mail this way with paragraphs and username/password?

Regarding the translation plugin I experience this error when trying to edit Norwegian language:

Error: The actual loaded translation content does not match the textdomain: s2member
Expect, that any text you translate will not occure as long as the textdomain is mismatching!
This is a coding issue at the source files you try to translate, please contact the original Author and explain this mismatch.

Posted: Wednesday Aug 15th, 2012 at 8:01 am #22068
Raam Dev
Username: Raam
Staff Member

This email notification is very basic, so HTML may not work here, but you can try this:

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 = "Ditt medlemsskap i TAN er nå aktivert!";
        $message = "Hei " .$user_info->display_name . ", din bruker på NewUtd.no er nå blitt oppgradert til medlem.
<p>
Du kan nå logge inn på medlemssiden og lese medlemsblader, laste ned høydepunkter, delta i konkurranser og så videre.
<p>
Medlemspakken med det første medlemsbladet, plakat og medlemskort blir sendt ut i september. De to andre bladene blir gitt ut i desember og mai.
<p>
Med vennlig hilsen
NewUtd-teamet";
        wp_mail($to, $subject, $message);
}
add_action( 'set_user_role', 'user_role_update', 10, 2);

I removed the username and password part of your example because those are not accessible at this point in the code. The password has already been set by the user and the password cannot be retrieved and displayed here.

Regarding translations, the Translating WordPress page may contain some helpful info.

Posted: Wednesday Aug 15th, 2012 at 12:11 pm #22119
Nordin Chena
Username: Nordino

Thanks!! That worked perfect.

The only thing left is that I discovered that new members that register on level 0 (subscriber) also receives this message. I only want it to be sent out automatically if a member is upgraded from level 0 to level 1 (medlem).

I feel bad about asking you all this stuff, and I hope this is just a small edit to the code :)

Posted: Thursday Aug 16th, 2012 at 6:44 am #22189
Raam Dev
Username: Raam
Staff Member

Hi Nordin,

This should work:

function user_role_update( $user_id, $new_role ) {
if ($new_role == "s2member_level1") {
	        $site_url = get_bloginfo('wpurl');
	        $user_info = get_userdata( $user_id );
	        $to = $user_info->user_email;
	        $subject = "Ditt medlemsskap i TAN er nå aktivert!";
	        $message = "Hei " .$user_info->display_name . ", din bruker på NewUtd.no er nå blitt oppgradert til medlem.
<p>
Du kan nå logge inn på medlemssiden og lese medlemsblader, laste ned høydepunkter, delta i konkurranser og så videre.
<p>
Medlemspakken med det første medlemsbladet, plakat og medlemskort blir sendt ut i september. De to andre bladene blir gitt ut i desember og mai.
<p>
Med vennlig hilsen
NewUtd-teamet";
	        wp_mail($to, $subject, $message);
        }
}
add_action( 'set_user_role', 'user_role_update', 10, 2);
Viewing 8 replies - 1 through 8 (of 8 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.