• mkocher

    (@mkocher)


    Hello,
    I’ve hired someone on fiver to help polish up the activity streak add-on I’ve been experimenting with, and he’s run into some issues. I was hoping you could shed some light on the subject.

    The developer is telling me that BadgeOS isn’t robust enough to award different badges on the same settings. (For example, if I award a badge for an activity streak of 3, I can’t award a different badge for an activity streak of 4). I don’t think this is the case.

    Here are the questions he’s asked me:

    how can i get the achievement id of the post with that activity streak?
    Or how can i get the achievement id of the badge with that streak?
    Or how can i award the specific badge if a user’s streak equals the specific badge? streak

    Is there a resource or suggestion I can pass on? I know it isn’t a lot to work with, so if there is anything else I can provide, please let me know.

    https://wordpress.org/plugins/badgeos/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael Beckwith

    (@tw2113)

    The BenchPresser

    What are streaks in this case? Just the order of achievements earned or something like that? Is this something that’s stored custom by this addon, or is it relying on data that the core plugin saves?

    I’d also have him look inside the includes/rules-engine.php file for usable functions/filters related to checking on eligibility for a given award.

    Thread Starter mkocher

    (@mkocher)

    The streak is the count of how many days a user has earned BadgeOS points in a row. It’s stored in the user meta. If they miss a day the streak is set to zero.

    I’ve uploaded a copy if you would like to take a look:
    http://spanish-academy.ca/project/badgeos-add-on.zip

    If it helps, a previous attempt is here:
    http://spanish-academy.ca/project/rejected.zip

    The rejected version was just a modified community add-on, but it had a different method of awarding the badge (rather than enter a value, it just had a bunch of repeated code).

    Thanks for taking a look.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Some quick thoughts. I find it odd that you’re mixing user and post meta saving in the badgeos_addon_bp_save_step() function from the steps-ui.php file. Not sure why you’re doing anything with user ID one there.

    Regarding the first two versions of the question above, since it’s all custom data you’re creating/saving, there’s going to be no built in way for us to make that association. However, if the achievement ID is ever present at the time of you updating the user meta, I’d recommend saving that as part of the user data.

    $streak_data = array();
    $current_achievement_id = 236;
    $streak_data[ $current_achievement_id ] = array(
        'current_streak' => 4,
    );

    The example above wasn’t tested, so be mindful of potential parse errors, I don’t think there will be. Regardless, it’d save the achievement ID as an index to the array, that would then be saved to the user meta. Something you could then fetch and reference when needing to after grabbing the user meta.

    Thread Starter mkocher

    (@mkocher)

    Thanks so much. I’ll pass it on and keep working. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom add-on question’ is closed to new replies.