Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aimahdi/ac3f1dfd9fd56aeff35c40ce51f4835d to your computer and use it in GitHub Desktop.

Select an option

Save aimahdi/ac3f1dfd9fd56aeff35c40ce51f4835d to your computer and use it in GitHub Desktop.
<?php
add_filter('fluent_community/can_view_members_page', function ($canView, $pageStatus) {
if (!is_user_logged_in()) {
return false;
}
if (!class_exists('\FluentCart\App\Models\Order')) {
return false;
}
$allowedVariationIds = [12, 24, 80];
$user = wp_get_current_user();
if (!$user || !$user->exists() || empty($user->user_email)) {
return false;
}
$userEmail = strtolower(trim($user->user_email));
$orders = \FluentCart\App\Models\Order::with(['order_items:id,order_id,object_id'])
->where('payment_status', 'paid')
->whereHas('customer', function ($query) use ($userEmail) {
$query->whereRaw('LOWER(email) = ?', [$userEmail]);
})
->get();
$variationIds = $orders
->flatMap->order_items
->pluck('object_id')
->map('intval')
->unique()
->toArray();
$allowedVariationIds = array_map('intval', $allowedVariationIds);
return !empty(array_intersect($variationIds, $allowedVariationIds));
}, 10, 2);
@aimahdi
Copy link
Author

aimahdi commented Dec 30, 2025

How to use the snippet: https://somup.com/cTlvl9SeFm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment