A A A

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Integrating "Cubepoints" into Simple:Press 4.0
Jan 24, 2009
6:06 pm
Ted
Guest

Thanks I appriciate you letting me know.

Jan 24, 2009
7:20 pm

SP Master
Forum Posts: 23587
Member Since:
Dec 10, 2006
Offline

I have accepted the task for 4.1 for a point system, so I will hopefully, be doing an initial look in the next month or so. Then comes discussions amongst the team in the best way to proceed (or abandon). but first, we need to get 4.0.1 out.. hopefully tomorrow…

Jan 26, 2009
6:23 am
Member
Forum Posts: 43
Member Since:
Mar 12, 2007
Offline

hm, seems i’m lost. as the sf-hook-template.txt/.php was reworked a bit with the latest release as it seems, it seemed to be a good idea to include my code alterations there instead of alterting a core sf-forum file like sf-database.php ..

anyway, these two extended functions do not seem to work as expedted as i always get some Call to a member function get_var() on a non-object in /abs/path/here/wp-content/plugins/simple-forum/forum/hooks/sf-hook-template.php on line 395 or similar.. Would you be able to shed some light or help out, Mr Papa? If you would take a look into this file, which is an exact copy of my sf-hook-template that would be too nice and probably easier than to post the code here!

Lines causing problems are #373 and #395. Follows the same logic as suggested – what am I missing? Any help would be appreciated as always! [Edit: Code alterations from line #329 on function sf_hook_post_save() work like a charm btw =)

Jan 26, 2009
6:56 am

SP Master
Forum Posts: 22131
Member Since:
Nov 9, 2008
Offline

The problem is your use of the $wpdb object. You need to make it global so just put

global $wpdb;

at the top of each function that uses it.

Also remember that you need to 'return' content not echo it. Generally speaking anything echoed will appear at the very top of the page.

Yellow Swordfish
Jan 26, 2009
7:43 am
Member
Forum Posts: 43
Member Since:
Mar 12, 2007
Offline

Damn, thats really a beginners' mistake – i should have seen that.. Sorry and thanks.
Anyway, what seems to work for post-removal perfectly well now, doesnt subtract ANY point when i delete a topic nor will it spit out any error message..

Code is (*.txt-File above accordingly update also):

function sf_hook_topic_delete($topicid, $forumid)
{
/* Additional CubePoints integration */
if( function_exists('cp_alterPoints') && is_user_logged_in() ) {
global $wpdb;
$starter = $wpdb->get_var("SELECT user_id FROM ".SFTOPICS." WHERE topic_id = " . $topicid);
cp_alterPoints($starter, -3);
}
return;
}
Jan 26, 2009
7:54 am
Member
Forum Posts: 43
Member Since:
Mar 12, 2007
Offline

And if you’re already on it.. function sf_hook_post_profile() – How can i access the user_ID of the user of the specific post? I would need to pass that to cp_displayPoints(); ..

Jan 26, 2009
10:46 am

SP Master
Forum Posts: 23587
Member Since:
Dec 10, 2006
Offline

i dont follow you. 

the post_profile hook as to do with displaying a user's profile and nothing to do with a specific post.  the 'post' part of the title indicates after the profile has been displayed.

Oct 7, 2009
10:04 pm
GameWaiter
Guest

Just to update the Cubepoints-SimplePress integration a bit… The sf-hook-template.php part wasn't working for me so I edited sf-post.php. This is all for Simplepress version 4.1.2.

To add 30 cubepoints at topic creation (line 265 of sf-post.php), this is what the code now looks like:

        update_sfnotice('sfmessage', __("Unable to Save New Topic Record", "sforum"));
        return;
    } else {
        # lets grab the new topic id
        $newpost['topicid'] = $wpdb->insert_id;
         if( function_exists('cp_alterPoints') && is_user_logged_in() ){
    cp_alterPoints(cp_currentUser(), 30);
  }

    }

I also changed the new topic notice to read around line 342 of sf-post.php "New Topic Saved and 30 GW Points Earned!".

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

Then, to add 10 points with a reply post, around line 364 of sf-post.php it now looks like this:

        update_sfnotice('sfmessage', __("Unable to Save New Post Message", "sforum"));
        return;
    } else
             if( function_exists('cp_alterPoints') && is_user_logged_in() ){
    cp_alterPoints(cp_currentUser(), 10);
  }

Unfortunately, I haven't yet found a way to remove points upon topic or reply deletion. Anyone have any luck with that? Thanks, phanthomas and mr papa, for all the help in this thread!

Oct 8, 2009
2:21 am

SP Master
Forum Posts: 23587
Member Since:
Dec 10, 2006
Offline

there is a program hook available when a post is deleted. you can hook in there and add your code or call the cubepoints api.

we still have an open ticket to do our own points type thing, currently slated for v5.0

Jan 22, 2010
9:06 am
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

I tried Gamerwatier's post and it is giving points for a brand new post creation! I'm on SPF 4.1.3 btw

But not for posts on a existing topic.

Here is the code I used for trying to give points for a post on a existing topic. It's around Line 357 under

# Create new Post in existing Topic ————————————————

 

# Write the post

    $newpost = sf_write_post($newpost);

    if(!$newpost['db'])

    {

        update_sfnotice('sfmessage', __("Unable to Save New Post Message", "sforum"));

        return;

            if( function_exists('cp_alterPoints') && is_user_logged_in() ){

        cp_alterPoints(cp_currentUser(), 5);

              }

    }

 

I haven't attemped to delete points if a post/topic is deleted just yet.

Forum Timezone: America/Chicago

Most Users Ever Online: 444

Currently Online: SPQC
59 Guest(s)

Currently Browsing this Page:
1 Guest(s)

See All Online Activity

Top Posters:

-Radio-: 1251

Lee H: 606

Luffer: 535

Conrad_Farlow: 485

jim: 478

neon: 263

ovizii: 240

Tal: 240

Member Stats:

Guest Posters: 2616

Members: 7328

Moderators: 1

Admins: 2

Forum Stats:

Groups: 5

Forums: 16

Topics: 10839

Posts: 79131

Moderators: Brandon C (158)

Administrators: Yellow Swordfish (22131), Mr Papa (23587)