Skip to:
Content
Pages
Categories
Search
Top
Bottom

Donate to Specific Users Only


  • Bicky
    Participant

    @blby

    Hi,

    I was wondering if there is a way to enable donation of points where users of site can donate to few specified users (rather than just anyone). Also, is there a way to allow donation only for points above X points? Thanks

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

  • Tosh
    Participant

    @xberserker

    Try this out – https://buddypress.org/community/groups/cubepoints-buddypress-integration/forum/topic/how-to-force-a-max-donation/

    I’ll think about specific users, because that’s something I’d like to limit as well.


    Bicky
    Participant

    @blby

    Hi,

    I improvise a bit on the codes you referred to in the link above for the user id. If i want to restrict donation to user id 8 only, i changed the last bits of those codes to:

    if ($uid2 == 8){
    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);
    } else {
    return(__(‘Error: You cannot donate to this user!’,’cp’));
    }
    return sprintf(__(“%s have been donated to %s”,’cp’),cp_formatPoints($points),$user_info->user_login) . ‘.’;
    }

    I tried and it worked. I am no developer though, just try and error. Do let me know if there is any downside in the way i improvised the codes.

    This however limit to 1 specific user only. Is there a way to limit to a few specific users?

    Thanks in advance for your help


    Bicky
    Participant

    @blby

    Ok, googled a bit and found this to be working for 2 specific users (user id 8 or 20)

    if ($uid2 == 8 OR $uid2 == 20){

    Question is, does it work for say 10 or 20 specific users? Can i continue with more “OR” ? Maybe there is a more efficient way than this. I am a newbie to this :)


    Tosh
    Participant

    @xberserker

    I don’t know of a better way other than OR this OR that

    I’ve modified this a little for my needs. This is saying they can only donate to these set users at these set point amounts:

    // Set Donation Ammounts
    if ($points == 150 OR $points == 250 OR $points == 50) {
    // Can Only Donate to these user IDs!
    if ($uid2 == 613 OR $uid2 == 969 OR $uid2 == 887){
    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);

    } else {
    return(__(‘Error: You cannot donate to this user!’,’cp’));
    }

    } else {

    return(__(‘Error: You did not donate the correct amount’,’cp’));

    }
    // END Donation Limit

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Donate to Specific Users Only’ is closed to new replies.
Skip to toolbar