Tecca
Forum Replies Created
-
Forum: Plugins
In reply to: [W3 Total Cache] Cloudflare Extension doesn’t save new zone in WP MultisiteI haven’t. In the meanwhile I’ve been clearing CF cache directly from Cloudflare instead, and using a single set of options for both sites. Not very ideal but it still “technically” works this way.
Forum: Plugins
In reply to: [Subscriptions for WooCommerce] Updating user meta upon subscription expiringI appreciate that, thank you!
Forum: Plugins
In reply to: [Subscriptions for WooCommerce] Updating user meta upon subscription expiringI thought about this in the wrong way, and it ended up being way more complicated because of the multisite setup I’m using. Not sure who this will be helpful for, but here’s what I ended up with down below.
Use case: a subscription expires, and I want to lock someone out of a 3rd party service when that happens. This is done via updating usermeta and running an additional function after all the checks.
/**
* Suspends a SPC account when a WP Swings subscription expires.
*
* This function hooks into the WP Swings subscription expiration action.
*
* @param int $subscription_id The ID of the subscription (wc_get_order)
*/
add_action('wps_sfw_expire_subscription_scheduler', 'spc_suspend_expired_spc_account', 10, 1);
function spc_suspend_expired_spc_account( $subscription_id ) {
// Exit early if no subscription ID is provided.
if ( ! $subscription_id ) {
return;
}
// Assume the subscription belongs to the second site (ID 2).
// You may need to verify this assumption by inspecting the database or using a more robust method.
// NOTE: Replace '2' with the correct site ID if the subscription is on a different sub-site.
$target_site_id = 2;
// Switch to the target site to ensure the correct tables are queried.
switch_to_blog( $target_site_id );
// Get the WooCommerce order object using the subscription ID.
$order = wc_get_order( $subscription_id );
// Get the user ID from the WooCommerce order object (with fallback for guest users).
$user_id = $order ? $order->get_user_id() : 0;
if ( ! $user_id ) {
$billing_email = $order ? $order->get_billing_email() : '';
if ( $billing_email ) {
$user = get_user_by( 'email', $billing_email );
if ( $user ) {
$user_id = $user->ID;
}
}
}
// Get the WP Swings specific subscription status using the WC_Order object's get_meta() method.
$status = $order ? $order->get_meta( 'wps_subscription_status', true ) : '';
// Restore the original site context.
restore_current_blog();
// Exit early if the order was not valid or no user was found.
if ( ! $order || ! $user_id ) {
error_log( 'SPC: No valid order or user found for subscription ID ' . $subscription_id . ' on site ' . $target_site_id );
return;
}
// Log the retrieved status to aid in debugging.
error_log( 'SPC: Retrieved WPS status for subscription ' . $subscription_id . ': ' . $status );
// Verify that the status is 'expired'.
if ( 'expired' === $status ) {
// Update user meta to mark the SPC account as expired.
// User meta is shared across all sites in a multisite network.
update_user_meta( $user_id, 'spc_account_status', 'expired' );
error_log( 'SPC: User meta updated successfully for user ' . $user_id );
// Call the custom function to suspend the SPC service.
// suspend_spc_account( $user_id );
} else {
error_log( 'SPC: Condition not met. WPS subscription status was ' . $status );
}
}What this does is simply check the
wps_subscription_statusand whether it’s expired or not. Every step has logging if you turn debugging on in WP, so you can see where each step might fail.wps_sfw_expire_subscription_scheduler(I still have no idea when this triggers tbh), whenever this event is triggered, the function will run automatically. Use the code below to test fire it for testing.- Multisite compatible. Whichever site you use it on, change the “2” above to that site number.
- Retrieves user’s subscription status and info, then alters
wp_usermetaviaupdate_user_meta, found outside ofwc_get_order— which is where WP Springs has the subscription info.
Change
spc_account_statusto your own meta key, or do something else (or more) entirely. For instance, I will call another function that does something else I need done. Example commented out.Test the solution:
// TEMPORARY function to manually test the cron job. -- TEMPORARY!!!
// DELETE or COMMENT this completely out when you're done, please.
function spc_test_spc_suspension() {
// Replace '429' with the ID of an expired subscription for testing.
$expired_subscription_id = 429;
// Call the original function directly with the test subscription ID.
spc_suspend_expired_spc_account( $expired_subscription_id );
// Add a confirmation message at the top of the website to ensure it ran.
echo "Test function has been run. Check the user meta data now.";
}
// Temporary trigger for testing.
// You MUST DELETE this line after testing.
// Visit example.com/?run_spc_test
if ( isset( $_GET['run_spc_test'] ) ) {
add_action('init', 'spc_test_spc_suspension');
}Forum: Plugins
In reply to: [Subscriptions for WooCommerce] Compatibility with tax plugins?Thanks for the response, Abhay.
For now I’ve just visually removed WP Swing’s table using CSS where the monthly (or yearly, etc) subscription value shows, keeping only the text “Renewal for [Monthly Service]” and having that near the final price after tax. Then on the order button, I made sure to display the order price with tax included.
However: I think removing the confusion of showing different prices is highly important. The plugin doesn’t take the total value in the cart or checkout after fees and taxes? Like through
woocommerce_cart_totals_order_total_html?Thanks for your time! I suppose this is technically a resolved issue since it’s just visual (the actual order value and renewal is set at the correct after-tax price), but I would highly consider seeing if you can display pricing after fees and taxes regardless of the plugins being used, such as using
$cart->get_total();which takes fees and taxes into account for those that don’t show taxes inclusive in the price.Just a suggestion, I’m sure you know best!
Whoops, seems I was mistaken. It’s true you can do what I mentioned above, but your plugin does have a feature that requires you to log in after a certain point — the new user created would need the activation email, which I was mistaken about (it did get sent after creating the user).
I don’t think there are any issues, although I do think a new user should have his password set before being allowed to create a subaccount. I think it’s better for user experience that way.
Forum: Plugins
In reply to: [Affiliates Manager] Suggestion: Subscriptions for WooCommerce compatibilityHey there. No, I don’t mean the official WooCommerce plugin, but the free one made by WP Swings (linked in my initial comment). I’ve noticed many plugins are compatible with this subscription plugin, and it’s actually a preferred alternative to WooCommerce’s official plugin for many of us.
I actually did attempt trying the plugin you made for the official WooCommerce (with this non-official subscription plugin), but I believe there are a couple of different hooks to be changed and it doesn’t work, understandably.
Just a suggestion as many thousands of people use that unofficial plugin and may want to use your Affiliates Manager in their subscription site.
Forum: Plugins
In reply to: [W3 Total Cache] Cloudflare Extension doesn’t save new zone in WP MultisiteHey Marko,
Here are the sites:
To answer your question, yeah, the value can be set in the Network Admin, but trying to set it in the subsite goes through the Cloudflare authorization only to still use the main
.ccwebsite after everything refreshes.Though I think the main issue is the checkbox for different website configs — I can’t actually edit the values in either the main website or subsite with that setting either checked or unchecked. I imagine the Cloudflare issue stems from that.
Thanks for the help!
Forum: Plugins
In reply to: [W3 Total Cache] Request failed when uploading to CDNHey Marko! Thanks for the suggestion with Push/Pull, I suppose I’ve been using W3 Total Cache for so long on my sites that I never moved over to Pull. I switched to Pull and it’s working great!
Forum: Plugins
In reply to: [W3 Total Cache] Request failed when uploading to CDNHey Marko. I’m using “Amazon Cloudfront over S3.” And yes, I can manually upload files to S3 and the CDN will serve them fine (WP Media files also automatically upload without me having to do anything).
Here’s a screenshot of the CDN page. I noticed “not authorized” near Cloudfront: could that be the issue? Tests pass when uploading and the upload transfer queue gets sent appropriately to the CDN when I manually push the files over.
View post on imgur.com
Thank you, @gaurav1092. I suppose what I was looking at may be through a different plugin (adding tracking to PayPal and selecting the carrier). I suppose it’s the Payment Plugins for PayPal WooCommerce that I should be looking at.
Forum: Plugins
In reply to: [Payment Plugins for PayPal WooCommerce] “Mark Order as Shipped” in PayPalThank you, the PayPal Actions button works well for my needs!
As for the automatic tracking, the plugin I’m using is Advanced Shipment Tracking for WooCommerce (I use it specifically for the Printful plugin) — not sure if you can or want to integrate with that, but there’s the info in case you do.
Thanks, Michael!
Hi there. CSV seems to be the only option, and it includes a lot of data. I was wondering if there was a way to only get the email addresses on their own.
Forum: Plugins
In reply to: [Heateor Social Login WordPress] YouTube membership dataThank you! I had the name@email option checked, but unchecking it is great for Discord logins (I wanted the info “permanent” and unchangeable by the end user).
As for the YT scopes: I will definitely send an email if I have the need in the future. I decided to only use Discord for now. Pulling membership and/or YT channel subscriber info may be useful in the future for what I’d like to do.
Hey, sorry about that. I did more testing and this plugin is actually fine, my fault! Just so happened another plugin broke at the same time when I updated both of them.