Support » Plugin: Achievements for WordPress » Updating own plugin for v3

  • Resolved Figotech


    Hi Paul,

    Let me start by saying that although the change from v2 to v3 affects a lot of things I think you’ve done some great work and moving to this format is for the best.

    I developed some months ago a little plugin that allows using an encoded URL to grant an achievement to the logged user. With the changes I need some help updating some core logic:

    THis is some of the code I used on v2 to get the achievement object then unlock it (I retreive it by slug)

    $decrypted = -decirpted achievement slug from the url-
    $original_achievement = new DPA_Achievement( array( 'type' => 'single', 'slug' => $decrypted, 'user_id' => $user_id ) );
    	$original_achievements =  array( $original_achievement );
    //here I pretty much retrieve the name, image and description, I assume ill get the image now with the thumbnail feature
    	$outputstring = "<div id='unlock-achieve'><h2>".$original_achievement->name. "</h2><div id='unlock-achieve-img'><img src='".
    	wp_get_attachment_url($original_achievement->picture_id)."'></div><div id='unlock-achieve-desc'>".$original_achievement->description.
    	"</div></div>"; //antes slug
    	//the unlock itself, I hope you kept this function on v3!
    	dpa_force_unlock_achievement($user_id ,$original_achievement->slug);

    As you can imagine, right now its the class constructor “new DPA_Achievement” the one that was removed, I have been poking around the source files but still can’t find the best way to retreive the achievement object.

    Another related question:

    When I updated from v2 to v3 I erased the Achievements page after the upgrade and the “archive” page doesnt list anything at all when I use the url:

    Did I miss something to set up? I can see the achievements section on the WP Dashboard and Individual achievements do show up.

    Thanks for all the hard work

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Paul Gibbs


    BuddyPress Lead Developer

    Hi Figotech,

    Thanks! To clarify: when you have a slug and a user ID, you want to know the function which awards that achievement to that user?

    Do you need the achievement object as well, or just trigger the unlock?

    The archive page should do look a little like this:
    * Try going to Settings > Permalinks in the WP admin (don’t change anything, just load the page), then go back to .com/achievements/ — see if it works.

    * If it doesn’t, if the old achievements page is in the trash, permanently delete it, and try the above again.

    Hi Paul,

    Yes, i need to know if dpa_force_unlock_achievement($user_id ,$original_achievement->slug); still works.

    I need both to trigger the unlock and the achievement object since I show things like the name and image on the trigger page as feedback.

    About the page: I still had it in the trash, deleting it did the trick and now see everything ok. Thanks!

    Plugin Author Paul Gibbs


    BuddyPress Lead Developer

    What you want is this function:

    For an example, look in the save_profile_fields() method (near the bottom of it). You’ll probably want to pinch the entire block of code under the “Award achievements! :D” comment.

    Worked like a charm, and actually your award popup is for sure better than whatever I was planning on showing.

    I noticed on the documentation that dpa_get_achievements is pretty much just a WP_Query enhanced with your special args, do I treat the resulting objects like any other post objects to access their properties like ID, name, slug etc???

    Oh and anotehr question, I don’t see anywhere the options to award or remove achievements (I use award type achievements) from users, where are they ?

    Plugin Author Paul Gibbs


    BuddyPress Lead Developer

    RE: WP_Query — yes.

    Edit a user profile in the WP admin, and scroll to the bottom.

    Hi Figotech. Before rebuilt their site I tried getting in touch with you to see what you managed to cook up with these url encoded badge awards. I’ve been talking with Paul for a bit about building such a function into the Achievements plugin itself, though perhaps you may have already done some of this work already. Willing to share?

    Sure thing, lemme prepare a the files, its some really simple stuff but should be easy to integrate or improve

    Many thanks Figotech. You can reach me at pmcvicker “@” .

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Updating own plugin for v3’ is closed to new replies.