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.
Awarding points for other actions
pavsid
New
Hi, i would like to award points for other actions such as every time they visit the forum, or every comment they make, discussion they start, etc.
I have Yaga installed, but can't see how to do it with this.
I also tried Karma, but thought that having points as well as Karma coins was too much, so i'd just like to keep it as points.
Is there something which allows this easily? Or will I have to create a plugin?
0
Comments
You have to create a custom rule. Look here (or at your own installation) to see examples: https://github.com/hgtonight/Application-Yaga/tree/master/library/rules
Here's an example of how you can get help, once you have started
http://vanillaforums.org/discussion/28754/help-with-new-discussionwordmention-custom-rule#latest
Oh I see, brilliant, thank you
And maybe hard boiled developers can use that: http://hgtonight.github.io/Application-Yaga/en/class-YagaRule.html
Hmm actually, i'm not sure this will work - as doesn't the custom rule apply to badges? I don't want to award a badge necessarily, just award points
Thanks for trying my addon!
I have added the ability to award Yaga Points arbitrarily in the development version over on GitHub. It will be part of Yaga 1.1 once I get around to releasing it. You can award points with the following code snippet:
You have to specify an actual user,
$PointValue
must be an integer, and the last argument is a string that can't be longer than 10 characters.Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Thanks @hgtonight - is there much difference between that method and
UserModel::GivePoints
?For now i've simply put the following in my ThemeHooks class:
public function DiscussionModel_AfterSaveDiscussion_Handler($Sender) { if($Sender->EventArguments['Insert']>0) { $Session = Gdn::Session(); UserModel::GivePoints($Session->UserID, 1, 'Discussion'); } }
.. and then intend on doing something similar for the
UpdateVisit
event.Is your implementation in Yaga 1.1 a better way of doing it?
It is almost identical.
Yaga::GivePoints
is currently just a wrapper forUserModel::GivePoints
. I have a few future plans that may change how points are awarded and usingYaga::GivePoints
will ensure any addons/modifications are not left in the dust, so to speak.Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Cool thanks, so what's different in Yaga 1.1 then? Is the dev version on Github the master branch?
Yes. There are a few things. Mostly they are improvements for developing Yaga addons. Full changelist here: https://github.com/hgtonight/Application-Yaga/compare/666fafe50cade7bcef58da7bd219a3c2730336e8...master
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight Great addon btw! The gamification element was the only reason I decided to go with Vanilla Forums, and I didn't realise it wasn't included by default in the Open Source version! Thank YOU, for this!
Having a slight issue, and can't figure it out for the life of me!
I've created a hook:
Except that whatever the
$Set
variable in the sending methodUserModel::UpdateVisit
should be, is getting overwritten by theUserModel::GivePoints
call in my hook.I understand that
$Set
is passed by reference, and that theUserModel::GivePoints
call is overwriting this, but i've even tried instantiating a newUserModel
object in my hook, which still gives the same result.Does that make sense? Any ideas?
What
$Set
variable?UserModel::GivePoints
is a static function and will always execute the same regardless of what object calls it.Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
The
$Set
variable inUserModel::UpdateVisit
, which contains the fields to update against the user:I need those fields to remain the same.
Ah yes, of course. So how do I give the user some points, without affecting the original fields in
$Set
?You are handling an event that eventually fires the same event?
I would add a property onto the sending object and check for that existence at the very beginning of your handling function. If it exists, jump ship.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
No, i'm handling the
UpdateVisit
event, and then firing theGivePoints
event.Ah... I see what is happening. The
$Sender->EventArguments['Fields']
element is being used in two different events on the same object.Store it before calling the give points then restore it after.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Doh! Great idea. thanks