I have a client, Primal Vinyasa, which I’ve built an extensive membership site for. The top product worth promoting and we want to retain is the Monthly Subscription. To encourage retention, it’s worthwhile to figure out all the pain points customers have. For the monthly subscriber just wanting to access their member content, signing in via the My-Account page can be frustrating as this doesn’t get them their content, but rather, the WooCommerce My Account Dashboard. Even with modifying the dashboard template via the theme so that there’s a big ol’ obvious link to the content, they still get distracted with all the account management buttons:

example of the WooCommerce Dashboard

What we wanted to do is instead to redirect them to our new content starting page, as seen below:

Screenshot of our new Subscriber Content landing page

I’ve also included a “hide introduction” checkbox on this page so that after watching/reading it once, a user can click the box to hide that section. Through the usage of LocalSession, the browser will remember their preference. I’ll write a blog post on that later.

Skyverge, the developers of the WooCommerce Membership plugin have a post about how to Create a “My Memberships” section shortcode with WooCommerce Memberships: https://www.skyverge.com/blog/create-memberships-section-shortcode-woocommerce-memberships/. However, because the Primal Vinyasa website also lists products for sale that don’t have anything to do with online video content, I wanted to make sure that the customers who are buying rose oil will still go to the traditional WC dashboard.

I found an article over at https://memberfix.rocks/redirect-membership-woocommerce/ that helped get me started down the path and UX I wanted. The code they provided had some errors in it, and it was intended for logic for multiple membership landing pages. What you’ll find below is my modifications for our Primal Monthly Subscriber membership. I hope it’s useful

<?php
function mfix_show_memberships_details ($curr_user_id) {
	if ( is_admin() ) {
		return;
	}
	$customer_memberships = wc_memberships_get_user_memberships( $curr_user_id );
	$former_subscriber = [];
	$active_subscriber = [];
foreach ( $customer_memberships as $customer_membership ) {
	$membership_plans = $customer_membership -> get_plan() -> get_name();
	$membership_plans_array[] = $customer_membership->get_plan()->get_name();
	$membership_plans_status = $customer_membership->get_status();
	$membership_plans_status_array[] = $customer_membership->get_status();
	if (($membership_plans == "Full Access Subscription") && ($membership_plans_status == "cancelled")) {$former_subscriber[] = "former_subscriber";}
	if (($membership_plans == "Full Access Subscription") && ($membership_plans_status == "expired")) {$former_subscriber[] = "former_subscriber";}
	if (($membership_plans == "Full Access Subscription") && ($membership_plans_status == "active")) {$active_subscriber[] = "active_subscriber";}
	}
	if(!empty($active_subscriber)){
		$current_stats = "active_subscriber";
		return $current_stats;
		exit();
	}
	else if (!empty($former_subscriber)){
		$current_stats = "former_subscriber";
		return $current_stats;
		exit();
	}
	else {
		$current_stats = "potential_member";
		return $current_stats;
		exit();
	}
}
function mfix_custom_user_redirect( $redirect, $user ) {
    $username = $user->user_login;
	$curr_user = get_user_by('login',$username);
	$curr_user_id = $curr_user->ID;
	$current_stats = mfix_show_memberships_details ($curr_user_id);
	if( $current_stats == "active_subscriber" ) {
	//	$redirect = "/start-here/";
		$redirect = "/content-index/";
	}
	if( $current_stats == "former_subscriber" ) {
	$redirect = "/my-account/";
	}
	return $redirect;
}
add_filter( 'woocommerce_login_redirect', 'mfix_custom_user_redirect', 10, 2 );

I placed this into a functionality plugin, because even if the theme changes, we’ll still want this same user experience.

I hope this helps others who might be wondering how to create an improved user experience for their membership sites.

9 Comments

    • What’s the use case here? The snippet is for front end customers, who hopefully aren’t typing in “mysite.com/wp-login.php” into their browsers.

  1. Hello! I can’t have it work, I save, no error msg but when I play my scenarios I’m not being redirected! I tried to put the membership Name or slug, in both cases it’s not workin!

    • Hello Ramy. First of all, are you sure that the code is firing? You could add in an console.log message to confirm this.
      Have you used query monitor? Where are you saving this to? A child theme’s function.php file?

      • Hello Gray,

        I did try in a snippet, in the custom plugin I created. In the console, I’m not seeing any error related to the code you provided. The only think I did it’s to change the membership name (I also tried using the snippet)

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.