POLJUBAC GROMA Majica kratka – prodaja putem interneta
30,00 € PDV je uključen
Lea Krivošić, kolovoz ’95.
Sastav: 100% pamuk
Tehnika izrade: sitotisak

Opis
Majica kratka – prodaja putem interneta
Za narudžbe iznad 60,00EUR, dostava je besplatna!
/** * Remove LifterLMS Membership when user has NO active WPSubscription subs left * - Works on cancel + expire hooks * - Safety: only unenrolls if user truly has 0 active subscrpt_order posts */ function wpsub_user_has_active_subscription( $user_id ) { global $wpdb; // "Active" here means: subscrpt_order not cancelled AND has _subscrpt_next_date meta. // (This mirrors the logic you're already using in your cancel shortcode query.) $active_sub_id = $wpdb->get_var( $wpdb->prepare( " SELECT s.ID FROM {$wpdb->posts} s INNER JOIN {$wpdb->postmeta} sm ON s.ID = sm.post_id WHERE s.post_type = 'subscrpt_order' AND s.post_status != 'cancelled' AND sm.meta_key = '_subscrpt_next_date' AND s.post_author = %d LIMIT 1 ", $user_id ) ); return ! empty( $active_sub_id ); } function wpsub_maybe_remove_lifter_membership( $subscription_id ) { error_log( '🧹 LifterLMS WPSub: Deactivation check for subscription ID ' . $subscription_id ); // Determine user_id same way you do on activation $user_id = get_post_meta( $subscription_id, '_customer_user', true ); if ( ! $user_id ) { $order_id = $subscription_id - 1; $order = wc_get_order( $order_id ); if ( $order ) { $user_id = $order->get_user_id(); error_log( '🧹 LifterLMS WPSub: Found user ' . $user_id . ' from order ' . $order_id ); } } if ( ! $user_id || ! is_numeric( $user_id ) ) { error_log( '❌ LifterLMS WPSub: No valid user_id for subscription ' . $subscription_id ); return; } $membership_id = 4067; // If user still has ANY active subscription, keep access if ( wpsub_user_has_active_subscription( (int) $user_id ) ) { error_log( '✅ LifterLMS WPSub: User ' . $user_id . ' still has an active subscription, keeping membership ' . $membership_id ); return; } // Remove membership access if ( function_exists( 'llms_unenroll_student' ) ) { $ok = llms_unenroll_student( (int) $user_id, (int) $membership_id, 'expired', 'any' ); error_log( $ok ? '🚫 LifterLMS WPSub: Unenrolled user ' . $user_id . ' from membership ' . $membership_id : '❌ LifterLMS WPSub: Failed to unenroll user ' . $user_id . ' from membership ' . $membership_id ); } else { error_log( '❌ LifterLMS WPSub: llms_unenroll_student() not available (is LifterLMS active?)' ); } } // Run on WPSubscription lifecycle events add_action( 'subscrpt_subscription_cancelled', 'wpsub_maybe_remove_lifter_membership', 10, 1 ); // hook exists in WPSubscription hooks list [page:1] add_action( 'subscrpt_subscription_expired', 'wpsub_maybe_remove_lifter_membership', 10, 1 ); // hook exists in WPSubscription hooks list [page:1] // (Optional) also handle "marked for cancellation" if your site uses it // add_action( 'subscrpt_subscription_marked_for_cancellation', 'wpsub_maybe_remove_lifter_membership', 10, 1 );
Skip to content30,00 € PDV je uključen
Lea Krivošić, kolovoz ’95.
Sastav: 100% pamuk
Tehnika izrade: sitotisak

Majica kratka – prodaja putem interneta
Za narudžbe iznad 60,00EUR, dostava je besplatna!