WordPress.org

Forums

Achievements for WordPress
[resolved] Award achievements and generate pop up (6 posts)

  1. Frix00
    Member
    Posted 2 years ago #

    Hi

    First of all, let me say thanks for a great plugin. I hope this plugin goes from strength to strength and the supported plugin list continues to grow.

    We're building a sort of quizzing site with lots of different quizzes. To cut a long story short, we didn't want / couldn't use Courseware for it, so we need to find a way to award achievements to our users completing the quizzes "manually".
    I'd like to write a piece of php/javascript that executes when the user successfully passes a quiz. This should basically award him the achievement relating to this quiz (we'll create 1 achievement per quiz) and also display the achievement pop up.

    Would you be able to point me in the right direction here ? What set of functions would be suitable to use here ?

    Happy to do some trial and error myself, but just thought I'd ask for some pointers.

    Thanks!!

    Greg

    https://wordpress.org/plugins/achievements/

  2. Frix00
    Member
    Posted 2 years ago #

    Hi

    Reading further into the plugin, it seems like the heartbeat function would actually do the job of creating the pop up to a user having been awarded a new badge, so presumably all I need to do is find a way to "manually" grant a badge to a logged in user via ajax/php upon completion of a quiz.
    Am I right in the assumption that the below chain would work:
    1. User creates a quiz
    2. My code grants an achievement to this user (that's the bit I need to figure out)
    3. The heartbeat code "detects" that the user has a new achievement and display the overlay

    If you could point me to the right php function that right help me award an achievement to a user, that would be great !

    Many thanks
    Greg

  3. Paul Gibbs
    Inactive
    Plugin Author

    Posted 2 years ago #

    Hi Greg

    Absolutely. Let me write up some docs this weekend because I've promised at least one other person, and I'll do a better job spending a few hours writing up a document rather than spending 10 minutes on a quick forum reply.

    In terms of what your quiz code needs to do, it's literally something like this.

    do_action('greg_is_cool', $user_id);

    Assuming you're familiar with WordPress actions and filters, you can call the action whatever you want, and for ease of integration with Achievements, pass a user ID as the first parameter.

    You'll only want to call your new action(s) whenever you've verified that the quiz was validated and completed successfully.

  4. Frix00
    Member
    Posted 1 year ago #

    Many thanks Paul.

    I see exactly what you mean, and yes a little bit of documentation would be fantastic, so please do let me know when you've had a chance to do it and post it online.

    I can then crack on with writing a little plugin that will check the quiz result, and grant the achievement if need be.

    Really appreciate thee help, thanks !

    Greg

  5. Paul Gibbs
    Inactive
    Plugin Author

    Posted 1 year ago #

    The documentation page for this is coming along well. I've written up a bunch of words, and next is working on a sample plugin that people can use a base for adding custom extensions to for Achievements. I might be able to work on that tomorrow night.

  6. Paul Gibbs
    Inactive
    Plugin Author

    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Achievements for WordPress
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic