0

I run a multiple author platform where Cubepoints is a major part of its point and ranking system.

I have added a custom category taxonomy called highlight and it contains two items: featured and spotlight.

Whenever an excellent post is submitted, an editor check it as featured or spotlight - both of which gives the article a lot of exposure on the site. If the users article is highlighted, they receives a custom amount of extra points. The problem is that the editors are forced to add these points manually by browsing to Cubepoints / Add Points.

This is an exhausting process to do manually. How can I make this work automatically? This means that if featured is checked for the custom taxonomy (highlight), then the user gets 30 points with the description "Your article has been featured", and if spotlight is selected, they receive 50 points with a similar form of description.

Unfortunately, the Cubepoints API documentation is noneexistent, however, I good tutorial was recently written by a user.

5
  • You want to add points to Cubepoints? Does Cubepoints have an API?
    – s_ha_dum
    Dec 7, 2012 at 15:11
  • @s_ha_dum The API documentation is very poor I'm afraid. However, some users have managed to write various tutorials such as this one: efieldguide.com/using-the-cubepoints-plugin-api Dec 7, 2012 at 15:13
  • Your link returns a 403
    – s_ha_dum
    Dec 7, 2012 at 15:15
  • It works perfectly fine here. Many your IP is blocked on their server by some reason, try accessing it through anon proxy. Dec 7, 2012 at 15:18
  • Update: You are right, upon refreshing the page, it gives a 403. Luckly I saved the page and uploaded it here: bogsorken.com/wpse/cubepoints Mind the styling issues... I am sure that the original site has some very random server issues atm. Dec 7, 2012 at 15:24

1 Answer 1

0

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.

1
  • Yes indeed, I want to hook into save_posts. I did not understand your third point. Is there any chance that you could kindly provide a code example that might guide me to the right direction? Dec 7, 2012 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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