By Dan Cote on Sunday, 27 August 2017
Posted in General
Replies 6
Likes 0
Views 231
Votes 0
I have a problem that has been asked about 2 times before by other users. I have a points rule that deducts points. We are trying to use it on https://rvpoints.com/points-deals so that a user would get a deal for "X" amount of points. We have a point rule that then deducts those "X" amount of points. The problem is that Easysocial allows the Points value of the user to go negative. We want to some how have a warning come up that if a deal is "2000" points and they only have earned "1500" points, then they are short on points and can't get the deal.

The points rule only tells Easysocial to deduct points, how might we be able to find out the total user points of a user? Is there some variable in the system for the Total user points? If so, then I can tell my developer to use the points rule but also have it do a check of the user's point total first and if the deduction goes negative to have a warning modal window come up saying they don't have enough points.

This relates to the following forum post: https://stackideas.com/forums/points-question

Any help on this would be appreciated. I think I have a possible concept on how to get this to work, but I need to know how to get to that User's Points Total.

thanks,

Dan Cote
Hey Dan,

I am really sorry for the delay of this reply as it is a weekend for us here. To get the number of points a user has, it's as simple as running the codes below,

[gist]
$user = ES::user();
echo $user->getPoints();
[/gist]
·
Sunday, 27 August 2017 12:44
·
0 Likes
·
0 Votes
·
0 Comments
·
I don't think that code work if another Joomla component is attempting to check for the point total.

What are the general MySQL queries for that getPoints function?

I'm thinking I'm going to just query that database for the total points of a user. What db table(s) would I need to look at...to find that info?
·
Monday, 28 August 2017 10:43
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Dan,

The general query to get certain user's point actually this:
[gist type="php"]
SELECT SUM(`points`) FROM `#__social_points_history` WHERE `user_id` = 432 AND `state` = '1'
[/gist]
in the #__social_points_history table (change the #_ to your database prefix)
·
Monday, 28 August 2017 12:05
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you Muhammad Fadhli for giving me that mysql query. I will test it and see if everything works.

Thanks Again!
·
Tuesday, 29 August 2017 10:31
·
0 Likes
·
0 Votes
·
0 Comments
·
Sure Dan
·
Tuesday, 29 August 2017 11:05
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post