By MD King on Tuesday, 24 November 2015
Posted in General Issues
Replies 8
Likes 0
Views 537
Votes 0
I want to set up a form that gives users points when they submit the form.
Unfortunately, the example rule file is not available in the documentation.

Documentation

I can add the custom code to the form, I just need to know how to call the code.
Thanks!
Hey MD King,

Thanks for reported, it seems like that download link is not correct, we will fix this in shortly. However, you can download my attached file for this.

I can add the custom code to the form, I just need to know how to call the code.

Regarding this, it depend on which operation you would like to add point to your site user.
For example : when the user invite his friend to join Easysocial, the sender will get the point.

STEP 1 : Create a xxx.points file then install through Easysocial point installer.
STEP 2 : Add this following code in which file is handle this invite friend function e.g. JoomlaFolder\administrator\components\com_easysocial\tables\friendinvite.php

			
// AT LINE 142 - 144
// Assign points to the user that created this invite
$points = FD::points();
// $points->assign('command', 'extensionName', userID);
$points->assign('friends.invite', 'com_easysocial' , $this->user_id);


Hope this help.
·
Tuesday, 24 November 2015 12:22
·
0 Likes
·
0 Votes
·
0 Comments
·
It seems like above code get striped, you can refer on my attached screenshot below.
·
Tuesday, 24 November 2015 12:23
·
0 Likes
·
0 Votes
·
0 Comments
·
I think I am getting it, for my purposes, can I set up a php file solely for assigning points/badges?
Check my thinking:
1 - Create Points or Badges File & Install
2 - Create .php page that does the work assigning.
3 - Use a function or operation that calls that page (activating the code)

What code needs to be in the page - I can add HTML and fancies later (animated adding your badge, assigning points) and then redirect the user.

Sorry, not a coder at all - just need a skeleton page to start with.

Thanks Alex!
·
Wednesday, 25 November 2015 05:03
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey there,

I am sorry for that delay of this reply,

Almost there, but if all the operation already existed in Easysocial, so you no need create another php file for that, you can directly add one more coding for your custom badge/point command in that operation function. I think I should explain when the user submit a story form in Easysocial, the system will trigger that point and badges function, so I believe you will understand the whole process.

For example :
JoomlaFolder\components\com_easysocial\controllers\story.php
LINE 299

// @badge: story.create
// Add badge for the author when a report is created.
ES::badges()->log('com_easysocial', 'story.create', $this->my->id, JText::_('COM_EASYSOCIAL_STORY_BADGE_CREATED_STORY'));

// @points: story.create
// Add points for the author when a report is created.
ES:: points()->assign('story.create', 'com_easysocial', $this->my->id);

Above code is under `create` function when the user submit a new story in Easysocial. If the user submit over 50 times (depend on how much `Frequency` you set from the .badge rule file) new story in Easysocial, system will send the badge to that user.

Reference link :
http://stackideas.com/docs/easysocial/developers/achievements/rule-file
http://stackideas.com/docs/easysocial/developers/achievements/logging
·
Wednesday, 25 November 2015 15:23
·
0 Likes
·
0 Votes
·
0 Comments
·
Arlex -

Afraid I got a little more confused by an existing example, how about a php file that has to be created?
Let's say - user buys payplan - the redirect is to the new php file - that way the badge is assigned.
If needed will do a call or anything to try and get this right - People who are paying me, really deserve a badge!

Mike
·
Wednesday, 02 December 2015 06:12
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey MD King,

I am really sorry for the delay of this reply,

If you create your own custom php file, you can use following code to trigger the badges/points function:

require_once( JPATH_ROOT . '/administrator/components/com_easysocial/includes/foundry.php' );

// @badge: story.create
// Add badge for the author when a report is created.
ES::badges()->log('com_easysocial', 'story.create', $this->my->id, JText::_('COM_EASYSOCIAL_STORY_BADGE_CREATED_STORY'));

// @points: story.create
// Add points for the author when a report is created.
ES:: points()->assign('story.create', 'com_easysocial', $this->my->id);

·
Wednesday, 02 December 2015 23:58
·
0 Likes
·
0 Votes
·
0 Comments
·
Ok - badge & points created successfully --
Created badge.php file (contents below).
Browsed to page while logged in - nothing assigned to user.
(There is a typo between manual001 & manual.001 - not an issue)


<?php

require_once( JPATH_ROOT . '/administrator/beta/components/com_easysocial/includes/foundry.php' );

// @badge: subscribe.plan
// Add badge for the user when subscribed to plan.
ES::badges()->log('com_easysocial', 'admin.task.manual001', $this->my->id, JText::_('COM_EASYSOCIAL_STORY_BADGE_CREATED_STORY'));

// @points: story.create
// Add points for the user when subscribed to plan.
ES:: points()->assign('admin.task.manual.001', 'com_easysocial', $this->my->id);

?>
·
Thursday, 03 December 2015 07:59
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey MD king,

I am sorry for the delay of this reply,

Hmm I have a little bit lost here, may i know this badge.php is it under any function file?

Or you just put whatever I suggested that code into this badge.php?

If yes, that was not correct.

Try download my custom example .badge and .points file and extract the zip file then install from backend > Easysocial > User Points/Achievement > install (upload these file through these separate installer)

When you view on the `User Points/Achievement` listing page, you will see your custom badge and point exist.

Then I want my site user whoever install application after 5/10 times then get my custom badge, so I have to put my custom badge/point command (e.g. apps2.badge || apps2.points) into Easysocial core function file e.g. JoomlaFolder\administrator\components\com_easysocial\tables\app.php
//LINE After 559

// my custom badges and point
$badge = FD::badges();
$badge->log( 'com_easysocial' , 'apps2.install' , $userId , JText::_( 'COM_EASYSOCIAL_APPS_BADGE_INSTALLED' ) );

$points = FD::points();
$points->assign( 'apps2.install' , 'com_easysocial' , $userId );


So when the user trying to install an application in his profile, it will get the point. Until installed 5/10 times (this value you can set it from backend Easysocial badge listing page) the user will get that custom badges.
·
Thursday, 03 December 2015 18:05
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post