1

I have built a web app that couples with a community built with JomSocial and I want to be able to award points to users within the community when they do things in the app. I already have ties to Joomla built in to my app, but I can't seem to find any documentation on how points work.

Any suggestions?

1

Thanks to @oooooo's recomendation I used this code to build a method for adding points.

Calling the UserPoints API in Your Code If you want to give points to a user, you will need to call the API by inserting the codes where you want them.

include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; include_once JPATH_ROOT.'/components/com_community/libraries/userpoints.php'; CuserPoints::assignPoint('your.action.string');

The your.action.string is the rule registered in database with how many points awarded to the current logged-in user. You will need to give a unique action string to your components such as 'com_name.profile.upload.avatar'. In some situations, where you want to give points to another user instead of the current logged-in user, you can call the API's in the following manner:

include_once JPATH_ROOT.'/components/com_community/libraries/core.php';
include_once JPATH_ROOT.'/components/com_community/libraries/userpoints.php';
CuserPoints::assignPoint('your.action.string', 62);

By giving the userId (62) as the second parameter, the API will give points to the specified user.

Here's the method I used. Hope it helps someone.

include_once JPATH_ROOT.'/components/com_community/libraries/core.php';
include_once JPATH_ROOT.'/components/com_community/libraries/userpoints.php';
function addPoints($user_id, $action_string = null){
    if($function_name == null){ $action_string = DEFAULT_ACTION_STRING; }
         CuserPoints::assignPoint('your.action.string', $user_id);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.