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

    (@tw2113)

    The BenchPresser

    Give this a try: https://gist.github.com/tw2113/49751cd81ecaee79a60d

    Something I worked up for a similar request a long time ago that I saved since I’d like to possibly have it put into BadgeOS core. It’ll be safe to go into your functions.php file for now though.

    Essentially gives you a shortcode of [badgeos_toolkit_earn_achievement_for_page_view] with achievement_id and the optional user_id as shortcode parameters. You’ll definitely want to set the achievement ID because that’s what tells the shortcode what to potentially award. The user ID is optional, and defaults to the current user. However, if for some reason you find need, you can set it to a specific user. The shortcode checks if it can award before doing so, so it shouldn’t keep constantly awarding each user.

    As a bonus, the above gist comes with support for the BadgeOS shortcode embedder, so you don’t need to memorize the parameters and can use the button above the editor :D.

    Thread Starter keeno1979

    (@keeno1979)

    Amazing! Thank you!

    So does this shortcode earn the achievement without directing the user to the “Congratulations you’ve earnt this achievement” page?

    I have just purchased the referral URL plugin, could I use this?

    Thread Starter keeno1979

    (@keeno1979)

    (sorry one more addition) – do I add that shortcode onto the destination page?

    I.e. User X goes to a page containing that shortcode (along with the ID part) and they are instantly awarded that badge? Without a notification?

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Yes, it won’t redirect the user anywhere, but probably could with a little modification. The Referral Add-on would work as well for this case, but the difference would be the user has to actually click on the link to earn it, instead of simply visiting the page.

    For my shortcode above, you put the shortcode on the page that you want the user to visit to earn. If you want to award them for contacting you about anything, you could have it run on the “thank you” page after they’ve submitted the contact form, as an example.

    Correct, without the notification part, that hasn’t been accounted for in the shortcode above. I could see it being possible if you have the Congratulations Addon as well, but that’s another separate addon that would need to be purchased first. This shortcode of mine is pretty basic and straightforward as is.

    Thread Starter keeno1979

    (@keeno1979)

    Amazing, thank you so much!

    This is exactly what I need to accomplish what we need. Last question now (I Promise!!!)

    I have added the code to the child theme functions.php file, and have the following shortcode on the destination page …

    [badgeos_toolkit_earn_achievement_for_page_view achievement_id=144383]

    However it doesn’t seem to be working …

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Have you confirmed if the achievement is showing in the earned achievements list for the user in question? Is it an achievement they’ve maybe already earned? Have you confirmed all of the associated steps are being met?

    Thread Starter keeno1979

    (@keeno1979)

    Hi there,

    Yes I can confirm that the achievement hasn’t been earned (it was previously, but has since been revoked from the test account)

    It is not showing in the earned achievements list for the user in question, and the steps are being met … there are no steps to the badge, as it’s marked as admin awarded only.

    I’m happy to provide login details should you require?

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    I’m curious if the earning limit has been reached and possibly if the admin-awarded only aspect is playing a part in it. Could you try with a new achievement and see if it still doesn’t award.

    Thread Starter keeno1979

    (@keeno1979)

    Ah yes, it looks as though it wasn’t awarding a previously revoked badge via the shortcode.

    Do super-admins automatically get awarded a badge without doing anything? It seems that’s happening but general subscribers get the achievement when they visit the page.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Shouldn’t be any difference between those two roles, in regards to achievements. I can’t recall anywhere in the code base that checks for current role.

    So just to recap, it is working overall, but wasn’t with the first test achievement due to earning caps?

    Thread Starter keeno1979

    (@keeno1979)

    Yes, it seems to be working now for non-admins which is really cool. I’ll continue to test it and will report back if I see any major issues.

    Thank you so much for your help, it’s been great!

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Badge Awarded when people visit a certain page?’ is closed to new replies.