Note: This is for CubePoints 3.0 and above

I’ve made this a little easier, no need to edit core files anymore. First do the following:

Find the file sf-hook-template.txt (simple-forum/forum/hooks/sf-hook-template.txt) and rename it to sf-hook-template.php. Save it in the same directory that sf-hook-template.txt was located in.

Search for this:

	  function sf_hook_post_save($newpost, $action)
	  {

Add this code right after that. The 25 is for how many points a new forum topic is worth and 5 is for a new reply in a existing topic.

	    global $current_user;
 
	     if ($action=="topic") {
	     	     cp_points('cp_spf_new_topic', cp_currentUser(), get_option('cp_spf_new_topic'), "");
	     }
	     if ($action=="post") {
	     	     cp_points('cp_spf_new_reply', cp_currentUser(), get_option('cp_spf_new_reply'), "");
	     }

Last step is saving extendcb.txt and renaming it as extendcb.php and placing it in this folder.

/wp-content/plugins/cubepoints/modules/

Then activate the module from the CubePoints Modules Page.


NOTE: THE BELOW ONLY WORKS ON CUBEPOINTS 2.1.4 OR BELOW

Want to give points for people that contribute to your Simple:Press Forum (SPF) using CubePoints? I’ve been using this method for the past few versions of SPF and it still works. Only downside is that you need to edit the file again after you upgrade SPF. It’s actually pretty easy, you just need to modify 1 file.

Go to /wp-content/plugins/simple-forum/library/sf-post.php

Since line numbers may change from version to version. Just search for this in the code:

# save the new topic record to db

Here is the original:

	# save the new topic record to db
	$newpost = sf_write_topic($newpost);
	if(!$newpost['db'])
	{
		update_sfnotice('sfmessage', __("Unable to Save New Topic Record", "sforum"));
		return;
	} else {
		# lets grab the new topic id
		$newpost['topicid'] = $wpdb->insert_id;
	}

Here is the modified code chunk:

	# save the new topic record to db
	$newpost = sf_write_topic($newpost);
	if(!$newpost['db'])
	{
		update_sfnotice('sfmessage', __("Unable to Save New Topic Record", "sforum"));
		return;
	} else {
		# lets grab the new topic id
		$newpost['topicid'] = $wpdb->insert_id;
		// Cubepoints Support
		  if( function_exists('cp_alterPoints') && is_user_logged_in() ){
			cp_alterPoints(cp_currentUser(), 25);
			cp_log('Forum Topic Creation', cp_currentUser(), 25, Forum);
		  }
 
	}

Now users will get 25 points for a creating a topic in your forum.

With Simple:Press Forum when topics/replies are added there is a pop-up message. I like to edit this saying how many points they earned.

Search for this:

update_sfnotice('sfmessage', '0@'.__("New Topic Saved", "sforum").$newpost['submsg'].' '.$newpost['emailmsg']);

This is how I edited mine:

update_sfnotice('sfmessage', '0@'.__("New Topic Saved and 25 Points Earned", "sforum").$newpost['submsg'].' '.$newpost['emailmsg']);

Next we need to give points for regular replies. Search for this:

# Write the post

Here is the original:

	# Write the post
	$newpost = sf_write_post($newpost);
	if(!$newpost['db'])
	{
		update_sfnotice('sfmessage', __("Unable to Save New Post Message", "sforum"));
		return;
	}

Here is the modified code chunk:

	# Write the post
	$newpost = sf_write_post($newpost);
	if(!$newpost['db'])
	{
		update_sfnotice('sfmessage', __("Unable to Save New Post Message", "sforum"));
		return;
		} else {
		// Cubepoints Support
		  if( function_exists('cp_alterPoints') && is_user_logged_in() ){
			cp_alterPoints(cp_currentUser(), 5);
			cp_log('Forum Reply', cp_currentUser(), 5, Forum);
		  }
 
	}

Pop up message for adding a reply.

Original:

update_sfnotice('sfmessage', '0@'.__("New Post Saved", "sforum").$newpost['submsg'].' '.$newpost['emailmsg']);

Modified:

update_sfnotice('sfmessage', '0@'.__("New Post Saved and 5 Points Earned", "sforum").$newpost['submsg'].' '.$newpost['emailmsg']);

If you want to change how many points are given change only the number values above and NOTHING else. I have this working with the latest version of Simple:Press Forum (4.2.2) and CubePoints (2.1.1) running WordPress 2.9.2

Download CubePoints | Download Simple:Press Forum

Thanks to the support at Simple:Press Forum for helping me and others figure this out.


Want to Integrate CubePoints into Buddypress?