WordPress.org

Ready to get started?Download WordPress

Forums

Achievements for WordPress
[resolved] Implement Custom Event (11 posts)

  1. atez1231
    Member
    Posted 1 year ago #

    Hi,
    if I wanted to implement another event, where should I do that?
    What I'm trying is basically if variable A equals variable b, output a notification and store the achievement somewhere.
    All your help is greatly appreciated!

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

  2. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    I haven't got any documentation for adding support for custom achievement events, just yet. If you're proficient with WP + PHP, take a look at the includes/extensions/ folder inside the Achievements directory.

  3. atez1231
    Member
    Posted 1 year ago #

    I've actually found a great documentation in includes/class-dpa-extension.php. Thank you!

  4. Peter Hudson
    Member
    Posted 1 year ago #

    Hi, I was wondering if you had added support for your event atez1231?

    I am not a beginner with php, but certainly not 'experienced'. The same with WordPress.

    I want to add support for another plugin I have, and I know what the action hooks are.

    I have looked in the directory suggested and created a file for the plug in - I'm assuming here that all that needs to be done is use the one php file, extending the DPAachievements class, list that as an include in the plugin and achievements will add the actions listed in array.

      But I'm struggling a bit
    - the plugin is recognized and listed in the available plugins, and the list of available actions is shown, but when adding an achievement the actions are not on the list.

    Whilst experimenting I managed to get it to appear on the list - I must have changed something or done something and then changed it again, the action was on the list, but any further ones added to the array did not get added and if I changed the description of the action it didnt change on the list - suggesting I had changed something for the worse..

    Anyway, I know you are working on the documentation Paul, but I was wondering if there was any basic documentation on what the file should look like - maybe for some other plug in that someone had put together that was not one of the built in ones.

    I could probably work it out from there?

  5. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    > Anyway, I know you are working on the documentation Paul, but I was wondering if there was any basic documentation on what the file should look like

    Not yet. I just got back from a trip, but I hope to get something written this week.

  6. Developer ICAN
    Member
    Posted 1 year ago #

    Hi Paul,

    I was just wondering was there ever any documentation created for this and even more importantly examples of how to add custom events?

    I'd like to add the following events if possible ...

    1) submit a gravity form
    2) Update a particular profile field

    I'm not building a new plug-in or anything, this is just functionality i'd like to hardcode into my functions.php or something?

    Any advice would be terrific!

  7. Developer ICAN
    Member
    Posted 1 year ago #

    Hi Paul,

    Just to be more specific,

    Is there a development way (i'm not building a plugin i just wanted custom events for a new site i'm building) ..

    1) You can add a new event say so that it appears in that new achievement drop down. I see from 3.3.1 that you can add events but i don't quite get what they are used for as they don't seem to appear in that drop down list when you're adding a new achievement? So for this example say i want to add an event for when a user submits a gravity form.

    add_action( 'achievements_add_custom_event', 'my_custom_event' );

    function my_custom_event() {

    // add a new event to achievements
    $parameters = {
    'name' => 'Submit Gravity Form',
    'description' => 'User submits a gravity form',
    'system' => 'Wordpress', // so it lists under WP, BP or BBP
    'slug' => 'custom_submit_gravity'
    }

    achievements_create_custom_event($parameters);

    }

    The above 'Submit Gravity Form' event would now appear in the new achievement dropdown.

    2) Hook into some action around the site and register with achievments that this event has occoured - ie something like ...

    add_action( 'gravity_submit', 'achievements_action_hook_example' );

    function achievements_action_hook_example () {

    // register that this user has submitted a form and let
    // achievements do the rest. 'custom_submit_gravity' is taken
    // from the slug registered above.

    achievements_event_occurred('custom_submit_gravity', $user_id);

    }

    Opps i've just spotted http://wordpress.org/support/topic/how-can-i-add-more-events?replies=6 and http://wordpress.org/support/topic/adding-more-actions?replies=6 - let me have a look!

  8. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    If you run into any trouble, please open a new thread.

  9. Developer ICAN
    Member
    Posted 1 year ago #

    Hi Paul,

    Brilliant, i've just created a few gravity form custom events! Thanks!! Really ahppyp about that!

    The graovity form actions are all in http://www.gravityhelp.com/documentation/page/Developer_Docs and i used your advice in http://wordpress.org/support/topic/how-can-i-add-more-events?replies=6 and Peter Hudson's sample code as you advised and i'm not hooking into Form submissions! Brilliant!

    Can i just ask you about the 'Events' in your latest release 3.3.1? What are they actually used for? I see they list all events in your system. So when i added those gravity form events via code they listed there but i see in 'Events' in the admin navigation that you can add events but they don't appear in the new acheivements event dropdown list and you can only add a title, slug and description? Is this just a phase of developement and you're planning on using them eventually? The add feature doesn't seem to make sense right now? am i right?

    Also see this part from Peter hudsons example ..

    //add support for love it pro to achivements
    function love_it_ach_init() {
    require 'Achievements-love-it/love-it-ach.php';
    }
    add_action( 'dpa_init', 'love_it_ach_init' );

    i'm not developing a plugin i'm just developing a theme. I have my code in the functions.php file. Do i need to call this dpa_init action underneath my code? I commented it out and it seems to work as normal?

    Lastly i've a quick question about other events i could create? I get what you mean about achivemenet events being just plugin actions so this means that where there's an action, there could be a custom event. But what about the likes of Javascript actions - 'Disgus' or 'share this' or an FB like?. Is there any way to hook into the likes of these? ie my client would like the action of sharing via sometihng like 'Share This' to register?

    Thanks Paul for everything! really impressed by how well this plugin is built!

  10. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 1 year ago #

    I have my code in the functions.php file. Do i need to call this dpa_init action underneath my code? I commented it out and it seems to work as normal?

    I would recommend you put all your custom achievement code into a helper plugin, and include it like I've recommended. It ensures things are loaded in the correct order, and that the custom code won't be executed when/if the Achievements plugin is disabled.

    . But what about the likes of Javascript actions - 'Disgus' or 'share this' or an FB like?. Is there any way to hook into the likes of these

    Not yet, but it's something I'd like to figure out someday.

  11. Developer ICAN
    Member
    Posted 1 year ago #

    Thanks Paul.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic