If a user gives someone karma send them an email letting them know.

Started by Phphelp, August 23, 2013, 09:46:54 AM

Previous topic - Next topic

Phphelp

I remember reading a post on here that someone wanted to do this..

Here's the code you will need to customize it based on the email message you want to send out.

In your sources/karma.php

Add this function

// Send the karma person a lovely email.
function emailKarma($template, $replacements = array(), $additional_recipients = array())
{
global $smcFunc, $sourcedir, $user_info;

// We certainly want this.
require_once($sourcedir . '/Subs-Post.php');

$request = $smcFunc['db_query']('', '
SELECT id_member, member_name, real_name, email_address
FROM {db_prefix}members
WHERE (id_member = ' . $_REQUEST['uid'] . ' )');

while ($row = $smcFunc['db_fetch_assoc']($request))
{

  $headers = 'PHP Help' . "\r\n";

// Then send the actual email.
sendmail($row['email_address'], $user_info['username'] . ' just gave you Karma on PHPHelp.com', $user_info['username'] . ' thought one of your posts was worthy of good karma! Thanks for contributing at www.phphelp.com/forum/', $headers);


}
$smcFunc['db_free_result']($request);

}


Next Find this..
// Change by one.
updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karma_good' : 'karma_bad' => '+'));


And under it add this.

//Send member an email here that's being updated.
emailKarma();

shadow82x

Colin B
Former Spammer, Customize, & Support Team Member


PierreP_whited00r_com

Can a user opt out of that as it can be annoying if a posts gets dozens of Karma's.

Phphelp

Not the way it's currently coded, would need to build it into the notification system, I didn't think about that.

PierreP_whited00r_com

No worries in our case because only the moderators can give Karma in our forum and we are not liberal with that.

I am sorry for not saying thank you in my post above for your neat idea. :-[

After we fix some stability issues we will give your script a try & report here.


MidasBalaa


playtony

Is it possible to have this activated just for particular users? I don't want that every user on our forum get this mail, but I would like that my administrators get it?

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: