Skip to:
Content
Pages
Categories
Search
Top
Bottom

Setting up Achievement Events with other plug-ins

  • Avatar of sdls
    sdls
    Member

    @simon_said

    Firstly Paul, AWESOME plug-in! I scoured the forumns but could not find this question, apologies if this is redundant. What is the best strategy for adding “events” from other plug-ins? For example GD star rating (another great plug-in that’s been around for years) would be an excellent tie-in to achievements.

    Noticing you have already included several other clutch plug-ins such as “Invite Anyone” in the stock “event” list… Has any body succesfully integrated another plug-ins actions with the events?

    achievements-core.php seems to contain the essential pieces on first glance.

    `function dpa_handle_action_accepted_email_invite() { $func_get_args = func_get_args(); dpa_handle_action( ‘accepted_email_invite’, $func_get_args ); }`

    which i’m hoping passes the action of a user accepting an invitation in the Invite Anyone plug-in, into the achievements ‘event actions’…..handled by this function…..

    `dpa_handle_action( $name, $func_args=null, $type=” )`

    The goal is to have “Plug-in GD Star Rating: – User Rated a Post” as an option when creating a new event based achievement. The level of complexity here is way over my head, any help would be greatly appreciated. Thanks thanks.

Viewing 18 replies - 1 through 18 (of 18 total)
  • Avatar of sdls
    sdls
    Member

    @simon_said

    or is it in the loader.php

    ` case 22:
    $wpdb->insert( “{$table_prefix}achievements_actions”, array( ‘category’ => ‘inviteanyone’, ‘name’ => ‘accepted_email_invite’, ‘description’ => __( “A new user activates their account.”, ‘dpa’ ), ‘is_group_action’ => 0 ) );
    $wpdb->insert( “{$table_prefix}achievements_actions”, array( ‘category’ => ‘inviteanyone’, ‘name’ => ‘sent_email_invite’, ‘description’ => __( “The user invites someone to join the site.”, ‘dpa’ ), ‘is_group_action’ => 0 ) );
    break;`

    Avatar of sdls
    sdls
    Member

    @simon_said

    Also….. just basic etiquette of how to add to this case statement from another “buddy” plug-in so the core can stay unmodified is truly mind boggling…

    Avatar of Paul Gibbs
    Paul Gibbs
    Keymaster

    @djpaul

    Hey Simon,

    Thanks for the kind words. And well done, you’ve pretty much figured out the basics of how it’s implemented. Check out http://achievementsapp.com/developer/add-support-for-a-plugin-non-custom-post-type/ for some more detail, and let me know if you need assistance.

    Avatar of Paul Gibbs
    Paul Gibbs
    Keymaster

    @djpaul

    p.s. this might be of use. It’s a couple of years old, so may need tweaking based on the above documentation; http://djpaul.dangerous-minds.net/example_achievements.phps

    Avatar of sdls
    sdls
    Member

    @simon_said

    Oh you mean on the site you made specifically for developers like me asking pesky questions….

    DOOOOIEEEEE c|:-P

    thanks for the help this looks like it has everything I need

    Avatar of sdls
    sdls
    Member

    @simon_said

    For posterity’s sake … if you want to build a plug-in to tie in other plug-ins or your own into achievements without mucking up the core… use this: http://wordpress.org/extend/plugins/buddypress-skeleton-component/ To put your functions in.

    Avatar of sdls
    sdls
    Member

    @simon_said

    A few more questions if you have a moment, thanks for getting back to me so fast the first time!

    “Add a new record to the achievements_actions table. The name column is very important. It must match the first argument of the do_action() call.”

    Do you mean adding this directly using mySQL admin tools? Or that by using the function…

    `function dpa_handle_action_bp_example_send_high_five() {
    $func_get_args = func_get_args();
    dpa_handle_action( ‘bp_example_send_high_five’, $func_get_args );
    }`

    it adds it for you?

    Avatar of sdls
    sdls
    Member

    @simon_said

    Bit of a newbie with this level of programming so thanks again for the feedback….

    I guess alot of this depends on the plug-in, so it’s a little ambitious to expect help on this … BUT… ;-) I have looked through all 235 files of the “GD Star Rating” plug-in and can only find a select few “add_action” calls, none of which relate to someone rating on a post “This is the action I’m trying to grab”…

    Does the “event” we’re registering in the achievements table need to be officially registered as an “action” or is there another way of referencing these user actions…. i.e. when someone rates a post.?

    thanks thanks

    Avatar of sdls
    sdls
    Member

    @simon_said

    P.S. Paul, if you’d like me to post these questions on your plug-in dev site, I can do that.

    Avatar of Paul Gibbs
    Paul Gibbs
    Keymaster

    @djpaul

    You can either add a record to achievements_actions directly with SQL, or you could do a little plugin to install it for you when it’s activated. Up to you.

    You need to look for do_action calls

    Avatar of sdls
    sdls
    Member

    @simon_said

    Hey there Paul,

    Thanks! found all the actions in the plug-in I want to dial in….

    // gdsr_vote_thumb_article
    // gdsr_vote_thumb_comment
    // gdsr_vote_rating_multis
    // gdsr_vote_rating_article
    // gdsr_vote_rating_comment

    awesome…. now I would really like to set this up as a plug-in for others to use…. do you have any easy to use snippets for adding a new achievement”action” to the achievement table?

    In the example: http://djpaul.dangerous-minds.net/example_achievements.phps… that this is manually triggering each achievement event rather then relying on the inherint functionality of the plug-in….I liked your example better, where you registered the “action” then used the core functionality of the achievements plug-in for all the heavy lifting…. i.e. unlocking, awarding, counting.

    Anywho… here’s what I got so far.. triggering a fatal error on activation…. any thoughts?

    This is placed in loader.php… of a new plug-in created from skeleton.

    ‘function achievements_tweaks_events_activate() {
    // add the new ‘action’ values for achievements into the achievements table.
    global $wpdb

    $achievement_category = ‘gdsr_vote’;
    $achievement_is_group_action = 0;
    $achievement_name = ‘gdsr_vote_rating_article’;
    $achievement_description = ‘The user rated a post’;

    $wpdb->insert( ‘wp_achievements_actions’, array( ‘category’ => $achievement_category, ‘is_group_action’ => $achievement_is_group_action, ‘name’ => $achievement_name, ‘description’ => $achievement_description), array( ‘%s’, ‘%d’, ‘%s’, ‘%s’ ) );

    }
    register_activation_hook( __FILE__, ‘achievements_tweaks_events_activate’ );’

    Avatar of sdls
    sdls
    Member

    @simon_said

    oops my bad… I missed a “;”…after global $wpdb..

    that worked a charm…

    I’ll post this plug-in when I’m finished…..

    Avatar of sdls
    sdls
    Member

    @simon_said

    Again … thanks so mUCH PAUL!!! YOU ROCK!

    Avatar of Paul Gibbs
    Paul Gibbs
    Keymaster

    @djpaul

    :) I noticed that old, old example_achievements.php was old and wasn’t working. If you can’t figure out anything from the documentation on achievementsapp.com, let me know, and I’ll copy/paste a new template version

    Avatar of sdls
    sdls
    Member

    @simon_said

    One last question (I hope) on setting this up as a companion plug-in without mucking up the works.

    When the user uninstalls the plug-in we want to remove all references across the 3 achievements tables to any related actions, achievements, or unlocks…

    Trying to use wpdb-> query to achieve this …. the same way i added them but am having difficulty.

    any thoughts?

    ‘function achievements_tweaks_events_deactivate() {

    // remove the actions from the table wp_achievements_actions table
    global $wpdb;
    $achievement_category = ‘gdsr_vote’; // make sure this title is unique to your plug-in

    // remove any associated achivements from the wp_achievements table
    $wpdb->query(“DELETE FROM $wpdb->wp_achievements A INNER JOIN $wpdb->wp_achievements_actions AA ON A.action_id = AA.id WHERE AA.category = ‘”.$achievement_category.”‘”);

    // remove the actions from the table wp_achievements_actions table
    $wpdb->query(“DELETE FROM $wpdb->wp_achievements_actions A WHERE A.category = $achievement_category”);

    // remove any unlocked achievement references to these actions.
    // we’el leave these hanging in case the achievement is reactivated.

    }
    register_deactivation_hook( __FILE__, ‘achievements_tweaks_events_deactivate’ );’

    Avatar of sdls
    sdls
    Member

    @simon_said

    as you can see above I’m trying numerous ways to reference the variable and complete this delete properly…. maybe this isn’t a plug-in question, but rather a syntax error in the $wpdb->query

    Avatar of sdls
    sdls
    Member

    @simon_said

    cannot get this $wpdb delete to work in it’s simplest form….

    `// register_activation_hook( __FILE__, ‘achievements_tweaks_events_activate’ );

    function achievements_tweaks_events_deactivate() {

    // remove the actions from the table wp_achievements_actions table
    global $wpdb;
    $achievement_category = ‘gdsr_vote’; // make sure this title is unique to your plug-in
    $wpdb->query(“DELETE FROM $wpdb->wp_achievements_actions WHERE ‘category’ = $achievement_category”);

    }
    register_deactivation_hook( __FILE__, ‘achievements_tweaks_events_deactivate’ );`

    Any thoughts would be greatly appreciated…. thanks…S.

    $wpdb->wp_achievements_actions doesn’t exist. Check how the table’s referenced in Achievements core.

Viewing 18 replies - 1 through 18 (of 18 total)

The forum ‘Achievements’ is closed to new topics and replies.