Created
December 30, 2025 12:51
-
-
Save aimahdi/ac3f1dfd9fd56aeff35c40ce51f4835d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use the snippet: https://somup.com/cTlvl9SeFm