Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   PM Users for Donation Alert (http://www.mysidiaadoptables.com/forum/showthread.php?t=5030)

Abronsyth 02-18-2016 02:51 PM

PM Users for Donation Alert
 
Resolved

I've looked at the functions that send a PM to a user when they receive a trade, but I couldn't figure this one out.

I'd like to make it so that when users receive a currency donation they also receive a PM that tells them;
"[Username] has sent you [amount] currency!"

Anyone have any ideas?

Kyttias 02-18-2016 03:29 PM

Try:
PHP Code:

$pm = new PrivateMessage(); 
$pm->setsender('SYSTEM'); // Or... whatever? You can change this.
$pm->setrecipient(htmlentities(addslashes(trim($recipient->username))));
$pm->setmessage("Donation For You!""{$mysidia->user->username} has sent you {$amount} {$mysidia->settings->cost}!");
$pm->post(); 

You could probably also have the sender be the user?
PHP Code:

$pm->setsender($mysidia->user->username); 

Here's the whole donate.php with the addition:
  Spoiler: donate.php 
PHP Code:

<?php

use Resource\Native\Integer;
use 
Resource\Native\String;

class 
DonateController extends AppController{

    public function 
__construct(){
        
parent::__construct("member");
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");        
        if(
$mysidia->input->post("recipient") and $mysidia->input->post("amount")){
            
$recipient preg_replace("/[^a-zA-Z0-9\\040]/"""$mysidia->input->post("recipient"));
            
$amount $mysidia->input->post("amount");
            
$recipient = new Member($recipient);            
             if(
$amount 0) throw new DonationException("negative");
            elseif(
$mysidia->user->money $amount) throw new DonationException("funds");
            elseif(
$recipient->username == $mysidia->user->username) throw new DonationException("user");
            else{
                
$mysidia->user->donate($recipient$amount);
                
$this->setField("recipient", new String($recipient->username));
                
$this->setField("amount", new Integer($amount));

                
$pm = new PrivateMessage(); 
                
$pm->setsender('SYSTEM'); // Or... whatever? You can change this.
                
$pm->setrecipient(htmlentities(addslashes(trim($recipient->username))));
                
$pm->setmessage("Donation Acquired""{$mysidia->user->username} has sent you {$amount} {$mysidia->settings->cost}!");
                
$pm->post();  
                
            }    
            return;
        }
    }
}
?>



Untested, of course. Luckily it appears to be super simple to implement notifications via PM!

Abronsyth 02-18-2016 03:56 PM

Sweet, it works perfectly!

Thank you very much <3

NobodysHero 04-06-2016 12:19 PM

Awesome! That was a great idea, Abronsyth! Thanks for sharing. 8D

Micolai 07-04-2020 01:14 AM

For some reason I keep getting an email that sends out to users after donations are made to them.


All times are GMT -5. The time now is 07:07 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.