WordPress.org

Ready to get started?Download WordPress

Forums

Achievements for WordPress
[resolved] Updating own plugin for v3 (10 posts)

  1. Figotech
    Member
    Posted 1 year ago #

    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:

    http://mydomain.com/achievements/

    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

    http://wordpress.org/extend/plugins/achievements/

  2. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    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: http://cl.ly/image/0H0k2w0J1y1Z
    * 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.

  3. Figotech
    Member
    Posted 1 year ago #

    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!

  4. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    What you want is this function: http://achievementsapp.com/function-reference/dpa_maybe_unlock_achievement/

    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.

  5. Figotech
    Member
    Posted 1 year ago #

    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???

  6. Figotech
    Member
    Posted 1 year ago #

    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 ?

  7. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    RE: WP_Query -- yes.

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

  8. pmcvicker
    Member
    Posted 1 year ago #

    Hi Figotech. Before Buddypress.org 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?

  9. Figotech
    Member
    Posted 1 year ago #

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

  10. pmcvicker
    Member
    Posted 1 year ago #

    Many thanks Figotech. You can reach me at pmcvicker "@" piercecountylibrary.org .

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic