How to force a max donation or set amount
-
This will require modifying 1 core Cubepoints file so make a backup!
In the file cubepoints.php search for this function:
`function cp_donatePoints($uid1, $uid2, $points) {`
was on line 174 for me:
This is the old code:
`
function cp_donatePoints($uid1, $uid2, $points) {
$points = (int)$points;
if ($points < 1) {
return(__(‘Error: You must donate at least 1 point!’,'cp’));
}
if (cp_getPoints($uid1) < $points) {
return(__(‘Error: Insufficient points to donate!’,'cp’));
}cp_alterPoints($uid1, -$points);
cp_alterPoints($uid2, $points);
//log
cp_log(‘donate’,$uid1,-$points,$uid2);
cp_log(‘donate’,$uid2,$points,$uid1);$user_info = get_userdata($uid2);
return sprintf(__(“%s have been donated to %s”,’cp’),cp_formatPoints($points),$user_info->user_login) . ‘.’;
}
`
Here is the new one, I have it so they can’t donate over 250 points:`
function cp_donatePoints($uid1, $uid2, $points) {
$points = (int)$points;
if ($points < 1) {
return(__(‘Error: You must donate at least 1 point!’,'cp’));
}
if (cp_getPoints($uid1) < $points) {
return(__(‘Error: Insufficient points to donate!’,'cp’));
}// Donation Limit 250 Max
if ($points > 250) {
return(__(‘Error: Donate only 250 Points at a time!’,'cp’));
} else {cp_alterPoints($uid1, -$points);
cp_alterPoints($uid2, $points);
//log
cp_log(‘donate’,$uid1,-$points,$uid2);
cp_log(‘donate’,$uid2,$points,$uid1);$user_info = get_userdata($uid2);
// END Donation Limit
}return sprintf(__(“%s have been donated to %s”,’cp’),cp_formatPoints($points),$user_info->user_login) . ‘.’;
}
`
I did this because of how I do giveaways, easier for me if they only donate 250 points at a time. Any idea how I can limit donation only to a certain account?Right now during my giveaway I have it set to 250 points exactly they can’t donate lower or higher than that.
`if ($points != 250) {`
Now if I could only force a max of 4 entries ..
You must be logged in to reply to this topic.