Using Fabrik form to update Alpha User Points

Status
Not open for further replies.

fabrikg09

Member
I am trying to add an AUP transaction from the results of a Fabrik form the user fills out; what I want to do is when the form posts, have the number of points the user fills in subtracted from his total AUP points. The process seems pretty straightforward. You insert the code for the AUP API, then create an XML file with your new rule (redeem_points), it should work:

// Get the user's input from the Fabrik field and put it in a variable, $debit //
$userid = $user->get('id');
SELECT `points` FROM `jos_alpha___userpoints` WHERE `id` = $userid;
$numPoints = $database->loadResult();

$debit = $formModel->_formData('jos_redeem_rewards_points___pointsrede emed');

//AUP API code //
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints '.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
AlphaUserPointsHelper::newpoints('plgaup_redeem_points', -$debit);
}

But when the form posts, nothing is inserted on the user's points transactions AUP db table...

There is a considerable amount of info on doing this - you have to drill down into the Google results to find it - but no one has really explained the entire procedure well, I think. Not much action on the AUP board, either.
 
I don't know about Alpha User Points but this
Code:
SELECT `points` FROM `jos_alpha___userpoints` WHERE `id` = $userid;
$numPoints = $database->loadResult();
won't do. You'll need something like
Code:
[COLOR=#000088]$database[/COLOR] [COLOR=#339933]=&[/COLOR]JFactory[COLOR=#339933]::[/COLOR][COLOR=#004000]getDBO[/COLOR][COLOR=#009900]([/COLOR][COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR] [COLOR=#000088]
[/COLOR][COLOR=#000088]$database[/COLOR][COLOR=#339933]->[/COLOR][COLOR=#004000]setQuery[/COLOR][COLOR=#009900]([/COLOR][COLOR=#0000ff]"[/COLOR][COLOR=#0000ff]SELECT `points` FROM `jos_alpha___userpoints` WHERE `id` = $userid"[/COLOR][COLOR=#009900])[/COLOR][COLOR=#339933];[/COLOR]
$numPoints = $database->loadResult();
 
Thank you. I think I was on the wrong track. I don't need that info from the database after all. What I need is to get the data that the user has filled in to the current form's field, called <points_redeemed>, I tried to do that like this:

//get the value in the form's field, "points_redeemed", and put that value in the variable, $debit //

global $fabrikFormDataWithTableName;
global $fabrikFormData;
$debit = $formModel->_formData('fds_redeem_rewards_points___pointsredeemed');

//Alpha User Points API //
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
AlphaUserPointsHelper::newpoints('plgaup_redeem_points',-$debit);
}

I think the AUP thing will work if I can successfully get the value into $debit from the Fabrik form field.
 
Thanks! I think that should help. I went over and signed in to Github. Do I have to update the whole Fabrik package? I couldn't seem to find just that plug. Sorry for my ignorance, as I don't do much with Github right now.

Well, I downloaded the whole thing and uploaded to the proper place.

I don't see the new plug-in for AUP anywhere.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top