<?php
/**
 * Examples for how to hide the banners based on the user's EDD purchase history.
 */
function my_swsales_show_banner_exclude_users_edd_examples( $show_banner, $active_sitewide_sale ) {
	// Return early if there is no logged in user.
	if ( ! is_user_logged_in( ) ) {
		return $show_banner;
	}

	// Get the current user object.
	$user = wp_get_current_user();

	// Check if user purchased a specific download.
	if ( function_exists( 'edd_has_user_purchased' ) && edd_has_user_purchased( $user->ID, '705' ) && ! current_user_can( 'manage_options') ) {
		$show_banner = false;
	}

	// Check if user has purchased any downloads.
	if ( function_exists( 'edd_has_purchases' ) && edd_has_purchases( $user->ID ) && ! current_user_can( 'manage_options') ) {
		$show_banner = false;
	}

	return $show_banner;
}
add_filter( 'swsales_show_banner', 'my_swsales_show_banner_exclude_users_edd_examples', 10, 2 );