Advertisement:

Author Topic: If a user gives someone karma send them an email letting them know.  (Read 12718 times)

Offline Phphelp

  • Semi-Newbie
  • *
  • Posts: 68
  • Gender: Male
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

Code: [Select]
// 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..
Code: [Select]
// Change by one.
updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karma_good' : 'karma_bad' => '+'));

And under it add this.

Code: [Select]
//Send member an email here that's being updated.
emailKarma();

Offline shadow82x

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,279
  • Gender: Male
    • cmblaber on LinkedIn
Re: If a user gives someone karma send them an email letting them know.
« Reply #1 on: August 23, 2013, 10:39:36 AM »
I moved this over to the right forum. :)
Colin B
Former Spammer, Customize, & Support Team Member

Offline Phphelp

  • Semi-Newbie
  • *
  • Posts: 68
  • Gender: Male
Re: If a user gives someone karma send them an email letting them know.
« Reply #2 on: August 23, 2013, 11:10:28 AM »
Thanks, I didn't know where to post my minor mods! I do now!

Offline PierreP_whited00r_com

  • Semi-Newbie
  • *
  • Posts: 37
  • Gender: Male
  • Everything is Relative
    • Whited00r on Facebook
    • Whited00r Custom iOS Firmware for iPhone 2G, iPhone 3G and iPod Touch 1G & iPod Touch 2G
Re: If a user gives someone karma send them an email letting them know.
« Reply #3 on: August 26, 2013, 11:48:34 PM »
Can a user opt out of that as it can be annoying if a posts gets dozens of Karma's.

Offline Phphelp

  • Semi-Newbie
  • *
  • Posts: 68
  • Gender: Male
Re: If a user gives someone karma send them an email letting them know.
« Reply #4 on: August 28, 2013, 08:37:48 PM »
Not the way it's currently coded, would need to build it into the notification system, I didn't think about that.

Offline PierreP_whited00r_com

  • Semi-Newbie
  • *
  • Posts: 37
  • Gender: Male
  • Everything is Relative
    • Whited00r on Facebook
    • Whited00r Custom iOS Firmware for iPhone 2G, iPhone 3G and iPod Touch 1G & iPod Touch 2G
Re: If a user gives someone karma send them an email letting them know.
« Reply #5 on: September 02, 2013, 12:21:14 AM »
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.

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,781
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: If a user gives someone karma send them an email letting them know.
« Reply #6 on: September 16, 2013, 07:38:34 PM »
Very nice!

Offline MidasBalaa

  • Semi-Newbie
  • *
  • Posts: 39
  • Gender: Male
  • I can't stop!
    • @makoani_j on Twitter
    • Hostbora.com Web Hosting and Domains
Re: If a user gives someone karma send them an email letting them know.
« Reply #7 on: November 06, 2013, 10:09:00 AM »
Very good. Keeps people coming back to the forum

Offline playtony

  • Semi-Newbie
  • *
  • Posts: 22
Re: If a user gives someone karma send them an email letting them know.
« Reply #8 on: October 12, 2014, 12:42:30 PM »
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?

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,622
  • Gender: Male
    • Kindred-999 on GitHub
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.