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 22, 2010
12:39 pm

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

no access to code currently – at work.. so cant tell where you ahve the hook…

in sf-post.php there is two code sections, one for new topics and one for new posts… make sure you didnt put it in the new topics section…

Jan 27, 2010
10:36 am
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

Giving points for topic creation and replies works now! Even logging works within cubepoints :D

 

But when I delete a post/topic. It deletes the points from my account and not from the user that replied in the topic, lol. Any ideas?

Jan 27, 2010
12:45 pm

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

how did you do the delete?? you probably need to modify the deletion code put in the delete hook and make sure its using the right id…

Jan 27, 2010
12:50 pm
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

This is in my sf-hook-template.php file. How would I make sure it's deleting the points from the user that posted in the forum?


function sf_hook_topic_delete($topicid, $forumid)
{
if( function_exists('cp_alterPoints') && is_user_logged_in() ){
cp_alterPoints(cp_currentUser(), -20);
cp_log('Forum Reply Deleted', cp_currentUser(), -20, Forum);
}
return;
}

function sf_hook_post_delete($postid, $topicid, $forumid)
{
if( function_exists('cp_alterPoints') && is_user_logged_in() ){
cp_alterPoints(cp_currentUser(), -5);
cp_log('Forum Reply Deleted', cp_currentUser(), -5, Forum);
}
return;
}

Jan 27, 2010
1:03 pm

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

when you delete the topic or post, you need to grab the poster id and return that to the alter points instead of the current user…

you have the postid and topic id, so do a db query to grab the poster id…

Jan 27, 2010
1:36 pm
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

I updated my code. Still not deducting points from the forum poster.

 

function sf_hook_topic_delete($topicid, $forumid)
{
 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, -20);
cp_log('Forum Reply Deleted', cp_currentUser($starter), -20, Forum);
 }
  return;
}
function sf_hook_post_delete($postid, $topicid, $forumid)
{
 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, -5);
cp_log('Forum Reply Deleted', cp_currentUser($starter), -5, Forum);
 }
return;  
}
Jan 27, 2010
6:57 pm

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

I dont know how that cubepoints works, but…

the first one, why would you check logged in??? that would require the topic starter to be logged in for points to be deducted… and do you want to deduct just for the topic starter or all posters in the topic?

the second one, you are checking the topics table, but you want to check the posts table and the post id… and same question about logged in check…

Jan 31, 2010
1:19 pm
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

True, you wouldn't need to check if they are logged in for deletion of forum topics/replys.

do you want to deduct just for the topic starter or all posters in the
topic?

I guess the topic starter.

Jan 31, 2010
1:32 pm

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

then you just need the user_id on the topic

Aug 16, 2010
3:02 pm
TwistedFang
Guest

xberserker,

 

I took your code you put into your sf-hook-template.php

 

I replaced  cp_currentUser($Starter)  with only ($Starter)

 

I have it working for deleting posts,  but still won't work when deleting a topic.

Forum Timezone: America/Chicago

Most Users Ever Online: 444

Currently Online: Yellow Swordfish, SPQC, steve.engelking, irlandes1, MacBravO
54 Guest(s)

Currently Browsing this Page:
1 Guest(s)

See All Online Activity

Top Posters:

-Radio-: 1251

Lee H: 606

Luffer: 535

Conrad_Farlow: 502

jim: 478

neon: 263

ovizii: 240

Tal: 240

Member Stats:

Guest Posters: 2626

Members: 7363

Moderators: 1

Admins: 2

Forum Stats:

Groups: 5

Forums: 16

Topics: 10895

Posts: 79576

Moderators: Brandon C (162)

Administrators: Yellow Swordfish (22236), Mr Papa (23688)