Skip to:
Content
Pages
Categories
Search
Top
Bottom

Suggested integration

  • Avatar of Hugo
    Hugo
    Moderator

    @hnla

    As you have integrated a number of other plugins to the points system i.e ‘Links’ it might be worth considering working in Boonegorges ‘Invite Anyone’ plugin. If the points system is used in the attempt to create and foster site activity then members inviting new members to join ought to be rewarded., probably on the acceptance of an invite e.g the members invite list shows an accepted ‘True’ in the DB rather than on the simple act of sending an invite otherwise joeuser@example.com might be sent rather a lot of invites.

Viewing 25 replies - 26 through 50 (of 62 total)
  • Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    @xberserker – I’m afraid I don’t know how the function cp_alterPoints works. Try printing the content of $inviter_id and $invitee_id just to make sure that they’re being fed to the argument. Beyond that you’ll have to dig deeper into CubePoints to figure out what’s going on.

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    I’m guessing the cp_alterPoints() function cannot handle two arguments.

    I would try duplicating the cp_alterPoints() function – one for the $inviter_id, the other for the $invitee_id. That way you’ll offer points to both users.

    Avatar of Tosh
    Tosh
    Participant

    @xberserker

    @r-a-y

    Good idea. Tried this below. Whoever clicked accept on the friend invite gets points twice. mmm Can I replace the cp_currentUser() function with something else that’s buddypress related?

    // Add Points for Accepting a Friend Request
    function my_bp_friend_add_cppoints($friendship_id, $inviter_id, $invitee_id) {
    if( function_exists(‘cp_alterPoints’) ){
    cp_alterPoints(cp_currentUser($inviter_id), get_option(‘bp_friend_add_cp_bp’) );
    cp_alterPoints(cp_currentUser($invitee_id), get_option(‘bp_friend_add_cp_bp’) );
    cp_log(‘Friend Added’, cp_currentUser($inviter_id), get_option(‘bp_friend_add_cp_bp’), BuddyPress);
    cp_log(‘Friend Added’, cp_currentUser($invitee_id), get_option(‘bp_friend_add_cp_bp’), BuddyPress);
    }
    }
    add_action(‘friends_friendship_accepted’,’my_bp_friend_add_cppoints’, 10, 3);

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    Don’t use the cp_currentUser() function at all… just pass the variables.

    Avatar of Tosh
    Tosh
    Participant

    @xberserker

    @r-a-y

    Ahah! That worked! Thank You ray! :D

    Avatar of Tosh
    Tosh
    Participant

    @xberserker

    @boonebgorges

    I attempted this with the do_action ‘accepted_email_invite’
    No points where given. This is what I’m using currently. Same method I used for the new friend completed feature I just did with the latest update.

    // Add Points for members that accept a email invite to the site.
    function my_bp_email_invite_accept_cppoints($user_id, $inviters) {
    if( function_exists(‘cp_alterPoints’) ){
    cp_alterPoints($user_id, get_option(‘bp_email_invite_accept_cp_bp’) );
    cp_alterPoints($inviters, get_option(‘bp_email_invite_accept_cp_bp’) );
    cp_log(‘Email Invite Accepted’, $user_id, get_option(‘bp_email_invite_accept_cp_bp’), BuddyPress);
    cp_log(‘Email Invite Accepted’, $inviters, get_option(‘bp_email_invite_accept_cp_bp’), BuddyPress);
    }
    }
    add_action(‘accepted_email_invite’,’my_bp_email_invite_accept_cppoints’, 10, 2);

    Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    @xberserker – I think that $inviters is an array. So you’ll probably need to do something like

    foreach( $inviters as $inviter ) {
    cp_alterPoints( $inviter, ......
    cp_log( ...., $inviter .....
    }

    Avatar of Tosh
    Tosh
    Participant

    @xberserker

    @boonebgorges – My new code. Nothing showed up in the log for either member. On the “Sent Invites” page has today’s date under Sent & Accepted. Thanks for your help so far :)

    // Add Points for members that accept a email invite to the site.
    function my_bp_email_invite_accept_cppoints($user_id, $inviters) {
    if( function_exists(‘cp_alterPoints’) ){
    cp_alterPoints($user_id, get_option(‘bp_email_invite_accept_cp_bp’) );
    cp_log(‘Welcome to the Site’, $user_id, get_option(‘bp_email_invite_accept_cp_bp’), BuddyPress);

    foreach( $inviters as $inviter ) {
    cp_alterPoints($inviter, get_option(‘bp_email_invite_accept_cp_bp’) );
    cp_log(‘Email Invite Accepted’, $inviter, get_option(‘bp_email_invite_accept_cp_bp’), BuddyPress);
    }

    }
    }
    add_action(‘accepted_email_invite’,’my_bp_email_invite_accept_cppoints’, 10, 2);

    Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    @xberserker – It’s a bit hard to tell just from that what’s going on. Put print_r($inviters) at the very beginning of the function just to see what the variable looks like.

    Avatar of Tosh
    Tosh
    Participant

    @xberserker

    @boonebgorges Put that at the start. But didn’t see it print it out anywhere. Not sure where it would print it out actually.

    Avatar of gregfielding
    gregfielding
    Participant

    @gregfielding

    @hnla
    I’m trying to use your code snip to get cubepoints to work with wpmu and I got this error:
    “Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/housings/public_html/wp-content/plugins/cubepoints/cubepoints.php on line 199″

    Here’s line 199:
    $extraquery .= implode(“‘ AND “.$db_prefix.”users.user_login != ‘”,$filter_users);

    I haven’t seen too many others following up on this…were you able to get it to work?

    Thanks!

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    @gregfielding It does work or at least I have it working, I don’t see anything obviously incorrect, is that a period just before the first =

    try copying the block again and if it still doesn’t work post your block with the previous and last two lines of the original code so I can see if it matches mine.

    Avatar of gregfielding
    gregfielding
    Participant

    @gregfielding

    @hnla
    that is a period…you’ve got them on this line and the next…see page 1 of this thread.

    $user_info = get_userdata($uid2);

    return sprintf(__(“%s have been donated to %s”,’cp’),cp_formatPoints($points),$user_info->user_login) . ‘.’;
    }

    function cp_getAllPoints($amt=0,$filter_users=array(),$start=0){
    global $wpdb, $db_prefix;
    if($amt>0){ $limit = ‘ LIMIT ‘ . $start.’,’.$amt; }
    if (count($filter_users)>0){
    $extraquery = ‘ WHERE ‘.$db_prefix.’users.user_login != ”;
    $extraquery .= implode(“‘ AND “.$db_prefix.”users.user_login != ‘”,$filter_users);
    $extraquery .= ” ‘;
    }
    $array = $wpdb->get_results(‘SELECT ‘.$db_prefix.’users.id, ‘.$db_prefix.’users.user_login, ‘.$db_prefix.’users.display_name, ‘.$db_prefix.’usermeta.meta_value
    FROM `’.$db_prefix.’users`
    LEFT JOIN `’.$db_prefix.’usermeta` ON ‘.$db_prefix.’users.id = ‘.$db_prefix.’usermeta.user_id
    AND ‘.$db_prefix.’usermeta.meta_key=”.POINTS.”’.$extraquery.’
    ORDER BY ‘.$db_prefix.’usermeta.meta_value+0 DESC’
    . $limit . ‘;’
    ,ARRAY_A);
    return $array;

    }

    function cp_findRank($points) {
    global $wpdb;
    $result = $wpdb->get_var(“SELECT `name` FROM `”.CPRDB.”` WHERE `points` <= ".$points." ORDER BY `points` DESC LIMIT 1");
    return $result;
    }

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    @gregfielding Greg the only thing I can see that’s incorrect is this line:

    $extraquery .= " ';
    It should be:

    $extraquery .= singlequote backslash singlequote singlequote semicolon
    Can’t believe it took me so long to see that :(

    Not sure how it has become changed, it throws an error for me if I change to your example above but not exactly the same error message, so it might not be the whole issue?

    I’ll go back and check what I originally posted to see if that had the same error.

    We have a technical forum that can’t handle the posting of code hmm :evil:

    Avatar of gregfielding
    gregfielding
    Participant

    @gregfielding

    hmmm…

    You want me to pastebin you what I’ve got?

    Avatar of gregfielding
    gregfielding
    Participant

    @gregfielding

    @hnla,

    Just curious…what specifically does this snip it integrate? Writing new posts? Commenting? Blog creation?
    Just curious.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    It enables the widgets and shortcodes that print the lists nothing in cubepoints that needs to access users or usermeta tables will work as on WPMU it prepends the incorrect table prefix to the user and usermeta tables.

    I’m sure this can be sorted in a much more friendly fashion though all I need is a method to check whether the site is single WP or WPMU then I could simply flip flop the table prefix and not have to go near the SQL block. There has to be a basic check that can be run? is that a daft question feels as though there is an obvious check or global variable/array that holds that info that I ought to be aware of?

    Greg is it still not working for you?

    Avatar of Griffin Boyce
    Griffin Boyce
    Participant

    @glamgrif

    @hnla I’m having the same issue as @gregfielding, where it causes that same fatal error. Reverting back to the original removes the fatal error, but of course still gives the “invalid” error when I try to display the top users. I’ve tried on a page and with the widget, neither work. http://www.bizolly.com (bottom left)

    Warning: Invalid argument supplied for foreach() in /home/bizolly/public_html/wp-content/plugins/cubepoints/cubepoints.php on line 276

    Avatar of Griffin Boyce
    Griffin Boyce
    Participant

    @glamgrif

    Also, tried the backslash-fix in the new code and it didn’t change.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    Here’s the function block that needs replacing in pastebin (the variable to set the new DB prefix is required in addition)

    http://pastebin.com/Z3SG4nnc

    See if that helps?

    Avatar of Griffin Boyce
    Griffin Boyce
    Participant

    @glamgrif

    @hnla Nope. It still gives the same foreach error.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    Revised the variable $db_prefix so that it should work for either a single WP install or a WPMU install

    http://pastebin.com/AHhvHQcQ

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    At the moment can’t see what is going wrong here, could you paste a copy of your copied block or maybe whole file to pastebin?

    Avatar of Griffin Boyce
    Griffin Boyce
    Participant

    @glamgrif

    @hnla Sure! I forgot to mention that I’m using WPMU. Trying the latest fix from your pastebin creates a fatal error (WP actually gives a “page not found” error when trying to save the edit). It occurs to me that the code gives a specific prefix to look for. I’ll double-check, but I may have my table prefix set to something other than WP_

    my cubepoints.php file http://pastebin.com/u3HFGYH7

    Avatar of Griffin Boyce
    Griffin Boyce
    Participant

    @glamgrif

    After editing the file in cPanel, it works! Yay! It must be the added if($wpdb->prefix == 'wp_1_'){
    $db_prefix = $wpmuBaseTablePrefix;
    }else {
    $db_prefix = $wpdb->prefix;
    }

    After the define and load_plugin lines. My DB does have wp_ as the initial prefix.

Viewing 25 replies - 26 through 50 (of 62 total)

You must be logged in to reply to this topic.