Profile Update and Elggx Userpoints

I am using the elggx_userpoints plugin and would like to make further modifications and could use some help.

Right now, whenever a member clicks on 'Save' on their Edit Profile page, it triggers the profileupdate event, and that event triggers the userpoints being awarded. The issue is that even if the profile fields haven't really been updated, or even if they are all still empty, the event is still triggered and they still get points.

So I want to add a function that checks that the profile fields have actually been updated and, after some research, think that the best way of doing this might be to check if any of the rows in the database have been edited -- but I'm not sure how to do that.

Should I query the database directly? Or is there an existing function I can use to check? I tried looking in the lib but didn't see an existing function to call.

I'm still pretty new to PHP (about 1 year experience) and very new to Elgg (less than 6 months experience), so any help is much appreciated!


This is the function in the elggx_userpoints plugin now that adds the points if the profile has been updated. I modified it here to also check if the value of $row_updated is set to 1. Now I think that I just need to figure out how to check if the value of $row_updated is 1 or 0 :/


function elggx_userpoints_profile ($event, $type, $object) {

    if ($row_updated = 1 && $points = elgg_get_plugin_setting('profileupdate')) {

        if (function_exists('userpoints_add')) {
            userpoints_add(elgg_get_logged_in_user_guid(), $points, $event, $type, $object->entity_guid);
        }

    }

    return(true);
}

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking