Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Remove Renew button from the My Account page for customers with a cancelled subscription - WooCommerce Subscriptions
* This stops the renew button from appearing in the My Account page once an order's been cancelled
* @param array $actions List of actions that subscriptions can do with each subscription (on top of
* WooCommerce)
* @param array $subscriptions List of subscriptions' data belonging to the current user
* @return array List of action buttons that can happen with each subscription
function remove_renew( $actions, $subscriptions ) {
foreach ( $actions as $key => $action ) {
if ( array_key_exists( 'renew', $action ) ) {
unset( $actions[ $key ]['renew'] );
return $actions;
add_filter( 'woocommerce_my_account_my_subscriptions_actions', 'remove_renew', 10, 2 );
* Forbids the subscription to be renewed by setting 'can_subscription_be_renewed' to false. This works across the
* board, so no subscriptions will ever be able to be renewed.
* @param boolean $subscription_can_be_renewed The original value
* @param array $subscription Subscription data
* @param string $subscription_key The key for the subscription
* @param integer $user_id The ID of the user the subscription belongs to
* @return boolean true if renewal allowed, false if not
function forbid_renewals( $subscription_can_be_renewed, $subscription, $subscription_key, $user_id ) {
return false;
add_filter( 'woocommerce_can_subscription_be_renewed', 'forbid_renewals', 10, 4 );
Copy link

lisarae1 commented Apr 5, 2017

I can not seem to get this code to work. I have tried adding it to a few places in my-membership.php but the Renew button still appears. It is very important that we remove the Renew button since our product uses a different URL to renew and required a gravity form add-on to be filled out... adding it directly to the cart is just not an option.

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