Well, I have 2 solutions available. One from the main dev of BadgeOS, and one that’s kind of homebrewed from my head. Both are similar, but there are some differences as well. Conveniently both involve shortcodes.
My solution.
Create a shortcode that simply does a do_action( ‘my_custom_hook’ ), and use that shortcode in the page editor of your choosing. Then use an add_action with that hook and attach a callback function. Inside that function, use the badgeos_award_achievement_to_user() function, to set which achievement to award. The function will default to the current user, if you don’t provide a specific user. Documentation link below.
Example:
function mdb_my_custom_shortcode( $atts ) {
do_action( 'my_custom_achievement_action' );
return;
}
add_shortcode( 'my_custom_bos_trigger', 'mdb_my_custom_shortcode' );
function mdb_my_custom_achievement_trigger() {
$achievement_id = 1; //set to whatever ID it is for your desired achievement.
badgeos_award_achievement_to_user( $achievement_id );
}
add_action( 'my_custom_achievement_action', 'mdb_my_custom_achievement_trigger' );
This way, it’d run whenever that page is visited, and award to the current user. If you want to make this more robust and easier to set the achievement ID, you could amend the shortcode as is to accept attributes, one which would be the achievement ID.
https://badgeos.org/api/function-badgeos_award_achievement_to_user.html
Main Developer Solution:
This one is a bit more robust, and probably the more proper route. It adds a custom trigger that you want to have, to the “Earned by” dropdown. It then also creates a shortcode to add to the page editor that will listen for the “Earned by” step you set. However, given that it’s going to be one that’s available to set in any badge, you may want to limit how many times you use it. as the trigger would be the same for each page. It’d run risk of awarding multiple badges in a few areas of your site. A way around that, would be limiting the amount of times the badge could be awarded.
https://gist.github.com/brichards/06c2e95124b154142805
A second version of a shortcode that you could use: https://gist.github.com/brichards/82411186ef792680f038