The following snippet shows how to force some downloads to not trigger the “New download purchase” event.
In addition, there are commented lines with the events for “New free download purchase” and “New paid download purchase” events in order to apply this rule on these events too.
function my_prefix_exclude_downloads_for_new_download_purchase_event( $return = false, $user_id = 0, $requirement_id = 0, $trigger = '', $site_id = 0, $args = array() ) {
$triggers = array(
'gamipress_edd_new_download_purchase', // New download purchase
// Uncomment next lines if you want to add this check on free and paid download purchase event
// 'gamipress_edd_new_free_download_purchase', // New free download purchase
// 'gamipress_edd_new_paid_download_purchase', // New paid download purchase
);
// Check if this is the event we are looking for
if( $return && in_array( $trigger, $triggers ) ) {
$download_id = $args[0];
// If this is the download we want to exclude, then don't award to the user this
if( $download_id === 123 ) {
return false;
}
}
// Send back our eligibility
return $return;
}
add_filter( 'user_has_access_to_achievement', 'my_prefix_exclude_downloads_for_new_download_purchase_event', 10, 6 );