Award points if a specific custom taxonomy is selected – Cubepoints

The bulk of your question seems to me to be about Cubepoint’s API, with is off topic here. The WordPress part would be this:

  1. I am not sure how your system works, or is supposed too work, but it sounds like you want to hook into save_post, but I am guessing about that part. Maybe you are doing this with AJAX or with something on the front end.
  2. Check for your fields
  3. Use WP_HTTP to submit to Codepoint’s API, which doesn’t look that difficult to deal with– cp_api=user/login/billly/points/add/500 (or cp_api=user/id/5/points/add/500)
    It looks like you want wp_remote_get for that

It should look something like:

function mypoints($oost_id) {
    // check to see if you need to update your points
    // I don't know what all the parameters for that are but
    if ( $need_to_update_points === true) {
        $apiresponse = wp_remote_get("http://www.your-site.com/?cp_api_key=abc123&cp_api=user/login/billy/points/add/25/log/custom/Happy+Birthday!");
        // check api response for sanity
    }

}
add_action('save_post','mypoints');

I am not sure why the example in your tutorial is submitting to “your-site.com”. Maybe I didn’t read part of that carefully enough. 🙂 That is the idea though.