Skip to content

Instantly share code, notes, and snippets.

@williamsba
Created January 11, 2013 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save williamsba/4513362 to your computer and use it in GitHub Desktop.
Save williamsba/4513362 to your computer and use it in GitHub Desktop.
function dma_rewards_user_has_prereqs( $user_id = 0, $reward_id = 0 ) {
$user_id = dma_get_user_id( $user_id );
$args = array(
'post_type' => 'badge',
'connected_type' => 'badge-to-badgeos-rewards',
'connected_items' => $reward_id,
'nopaging' => true,
'supress_filters' => false
);
$connected = new WP_Query( $args );
if ( $connected->have_posts() ) :
while ( $connected->have_posts() ) : $connected->the_post();
if ( dma_check_if_user_has_achievement( $user_id, get_the_ID() ) ) {
continue;
}else{
//user does not have a prerequisite badge so return false
return false;
}
endwhile;
endif;
wp_reset_postdata();
//user has all prerequisite badges so return true
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment