Use a user meta entry to store the information that this user has received the coupon already. Then check this user meta before you print the button:
Plugin code:
function coupon_button()
{
$post_id = get_the_ID();
$user_id = get_current_user_id();
$coupons_received = (array) get_user_meta( $user_id, 'coupons_received', true );
if ( in_array( $post_id, $coupons_received ) )
return '';
return get_submit_button( 'Get Coupon', '' );
}
function update_coupon_status()
{
$user_id = get_current_user_id();
$coupons_received = (array) get_user_meta( $user_id, 'coupons_received', true );
$coupons_received[] = get_the_ID();
update_user_meta( $user_id, 'coupons_received', $coupons_received );
}
Template code:
print coupon_button();
And when you show the coupon, use the update function:
update_coupon_status();