Last active
October 2, 2017 08:23
-
-
Save X-Raym/c4da3f94c910cbbb39cb to your computer and use it in GitHub Desktop.
An add-on for Badgeos to display a pop-up when a user earn an achievement.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* STEP 1 : DISPLAY A SIMPLE MODAL WINDOW JAVASCRIPT ALERT WHEN AN ACHIEVEMENT IS EARNED */ | |
// Function for in wp_head : the javascript alert | |
function custom_badgeos_java_alert() { | |
$output='<script> alert("Bravo ! tu as gagné un badge !"); </script>'; | |
echo $output; | |
} | |
// Function to be called when the user get an achievement | |
function custom_badgeos_award_popup_test ( $user_id, $achievement_id ) { | |
//VARIABLES (not useful at this time) | |
// Grab the current user ID | |
$user_id = wp_get_current_user()->ID; | |
// Grab the current post ID if no achievement_id was specified | |
if ( ! $achievement_id ) { | |
global $post; | |
$achievement_id = $post->ID; | |
} | |
// call the pop_up in wp_head | |
add_action('wp_head','custom_badgeos_java_alert'); | |
} | |
// call master function | |
add_action( 'badgeos_award_achievement', 'custom_badgeos_award_popup_test', 10, 2); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Does this work? Where would you input that script?