XF 2.0 User Upgrade API

Hi,

I'm working on a key redemption system, where users can input a key, and their account will be upgraded to a specific user upgrade.

Here's the API function that I'm trying to utilize:
PHP:
upgradeUser(integer $userId, array $upgrade, boolean $allowInsertUnpurchasable, integer | null $endDate) : integer | false

After reading what Chris posted here, I was able to come up with this:

PHP:
        $userUpgradeModel = XenForo_Model::create('XenForo_Model_UserUpgrade');
        $userUpgradeModel->upgradeUser($username, $userUpgradeRecord, true);

I was able to get $username to return the user id of the inputted username, but I'm perplexed as to what I'm supposed to put as $userUpgradeRecord. I have an upgrade ID of 17, would I use that as $userUpgradeRecord?

Regards,
 
That's XenForo 1.5 code.
Ah, okay. I figured that I'd still be able to utilize it, as I'm still able to use the authentication API calls. Would I just have to recreate what it's doing in UserUpgrade.php to upgrade a user?
 
Last edited:
Yeah, XenForo 1.5 and 2.0 code are not interchangeable, the code base has basically completely changed. Can look into the XF2 dev docs for some general guidance on things.
 
Top Bottom