Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Accessing and updating values in database

Hello there.

I'm attempting to access my vanilla database and inserting/updating values in the database with some hard coded values.
I'm located in class.karmabankmodel, because I want to insert a given value to the db when a user receives karma.

The exact field I want to update is the RoleID field within the gdn_userrole table.

How do I access and update this field with a given value?

Also, I have a variable $UserID. How do I send the given value to the correct user?

Thank you for your interest.

Comments

  • Options

    Have a look at PurchasePremiumRoles plugin (with MarketPlace plugin), that would enable use to buy the role with karma.

    if that is not good enough, at least there is some code in there that demonstrates how to add/remove roles, you just need to make you own plugin, learning from that.

    if you use

    $KarmaBank = new KarmaBankModel($UserID);
    $BalanceRecord = $KarmaBank->GetBalance();
    $Balance = $BalanceRecord->Balance; // user balance
    

    if you create an instance of KarmaBankModel without the UserID parameter it will automatically use the session user.

    All you need to do now is choose some hook to periodically check the balance, taking into consideration their current roles, and upgrading where appropriate.

    I think that is enough information for you to give it a go.

    grep is your friend.

Sign In or Register to comment.