Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to force a max donation or set amount

  • Avatar of Tosh
    Tosh
    Participant

    @xberserker

    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 ..

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of carehoodadmin
    carehoodadmin
    Member

    @carehoodadmin

    Hi,

    very nice post! (and i saw it being linked to some sites)
    But the problem is, the donate point function in my buddypress website doesn’t even work.. when i click the “donate” link, it returns on a pop-up box with a header “donate”, but with blank field under it.

    i’m using wordpress 3.0.4, cubepoint 2.1.3, buddypress 1.2.8, and integration 1.8.2 => is this a compatibility problem?

    i would be very happy if you can tell me what is actually wrong… i’ve been trying out some ways but it is not solved

    thanks a lot before!!

    Avatar of Tosh
    Tosh
    Participant

    @xberserker

    @carehoodadmin Please download the CubePoints 2.1.4 Beta
    There is a link to it in the CubePoints BuddyPress Intregration Admin Page at the bottom.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.