• Resolved romanguro

    (@romanguro)


    Please answer me a simple question.
    Plug-in is good, but …
    I watched all the video tutorials on the site, probyval find the answer in the forum and FQ, but haven’t found an answer to a simple question:

    As I can give the Achievement to the user on the specific page.
    Some shortcode may be that can be inserted on the page, and when the user view the page, he receives an Achievement.
    or add condition to the badge: “Get rewarded when viewing the specific page”

    Something like this doing “Nomination Box”
    but why the user have to send something or write “the reason the nomination”

    I just want to give the Achievement to the user by viewing a specific page!
    How can I do this:)

    Thank You.

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

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

    (@tw2113)

    The BenchPresser

    Actually a pretty simple thing to accomplish, that I had a code snippet save for from a previous request for this.

    function romanguro_earn_achievement_for_page_view_shortcode( $atts = array() ) {
    
    	$atts = shortcode_atts( array(
    		'achievement_id' => 0,
    		'user_id' => get_current_user_id()
    	), $atts );
    
    	badgeos_maybe_award_achievement_to_user( $atts['achievement_id'], $atts['user_id'] );
    }
    add_shortcode( 'romanguro_earn_achievement_for_page_view', 'romanguro_earn_achievement_for_page_view_shortcode' );

    This will prevent the user from earning it multiple times, and to use it, simply place this in your page editor where you want to award it:

    [romanguro_earn_achievement_for_page_view achievement_id="#"]

    Replace the # with the actual ID of the achievement you want to award for it. Feel free to change the shortcode keyword or function names as necessary for your install. This would be something you put in a quick custom plugin or if anything your site’s functions.php file.

    Thread Starter romanguro

    (@romanguro)

    Thanks a lot:)
    It works!
    How can I put this shortcode into ‘Add BungeOS Shortcode’ menu button?

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Since I had the code handy from what I copied it all from, I just turned it into its own quick plugin for you, and altered descriptions, textdomains, function names for you http://cl.ly/000h3b0M180s

    Should match up to the previous snippets I provided, and add it to the popup as well.

    Thread Starter romanguro

    (@romanguro)

    That’s cool 🙂
    Thanks:)))

    but I think it’s should be in the next version of plugin, for sure.

    What code would I use to award a badge? It is a survey completed outside of word press, so I thought I’d go with admin award? But I cannot figure out how to award the badge when they have completed the survey.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    I would use either of these:

    badgeos_award_achievement_to_user( $args[ 'achievement_id' ], $args[ 'user_id' ] );
    badgeos_maybe_award_achievement_to_user( $args[ 'achievement_id' ], $args[ 'user_id' ] );

    However you’re going to need both parameters, the ID of the achievement to award, and the user ID. I can’t say how you’re going to get those values, because I am not familiar with your setup.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to give the Achievement on a specific page’ is closed to new replies.