WooCommerce Wednesdays: How to create a membership site with WooCommerce

CommerceCategory
24 min read
Bradley Taylor

As the ecommerce market becomes more competitive, brands must devise new ways to differentiate themselves. To do this, many create a membership program with WooCommerce to reward the brand’s most loyal customers.

Whether through discounts, community building or simply increased engagement, memberships programs help you provide more value.

With a well-made membership program, you can strengthen the connection with customers, maximizing their lifetime value and encouraging referrals of other members.

In this post, we will examine how to turn your WooCommerce store into a membership site equipped with exclusive content, products, and discounts.


Get help with anything WooCommerce

Whether you need help with a problem or adding new features, GoDaddy Managed WooComerce Stores gives you direct access to real WooCommerce experts — right from your WordPress Admin dashboard. From how-tos and demonstrations to managing products and configuring extensions, GoDaddy’s advanced WooCommerce support is ready to help with your most advanced user inquiries.


What are the benefits of offering membership plans with WooCommerce?

Increased customer retention and lifetime value

One of the most notable advantages of a membership program is the immediate improvement in customer retention rate. When someone joins your program, they are more likely to continue doing business with you long term. The perks of a membership plan give customers a reason beyond your products to engage with your business.

Improved engagement

Membership programs are a great way to increase customer engagement. When someone joins your plan, they are more likely to read emails and your other forms of content. As you begin to build a connection with customers, many will become brand advocates. They will spread the word about your business to their family and friends.

Higher average order value

With a membership plan, you have more opportunities to cross-sell items across your catalog. Customers with whom you already have an established relationship will be more receptive to you marketing complementary products.

Plus, if users need to pay for a membership they, will feel more inclined to buy more items and earn more incentives in order to justify the cost of the program.

Recurring revenue

Paid membership plans can give you predictable, recurring revenue. By creating a recurring source of revenue for your business, you can better weather the ups and downs of the typical retail cycle.

Gain feedback from customers

Your most loyal customers are also the ones most likely to give you feedback. You can use your membership plan as a way to ask your customers about what they value the most and how you can improve.

Steps to create a membership site with WooCommerce

1. Set up the WooCommerce Memberships extension

While packed with features, the out-of-the-box version of WooCommerce does not offer support for membership plans. If you want to turn your ecommerce store into a hub for your most loyal customers, you will need to set up a memberships extension.

There are a few good choices available. My preferred tool for offering membership benefits is the WooCommerce Memberships extension.

With the extension, you can create stand-alone membership plans for customers to purchase. You can also include membership as an add-on to a product purchase. With member discounts, you can offer special promotional pricing to plan members.

2. Create a member plan

To create a membership plan, go to WooCommerce > Memberships > Membership Plans and click add new.

Name the plan and set the membership length. You will also need to determine how to grant users access to the membership plan. With user account registration, your customers can join the plan by signing up for a customer account for your store.

If you want to create a paid plan, you will need to select product(s) purchase and then create a product in WooCommerce for the membership plan. Memberships can be tied to any kind of product on your site. This including simple products, a variable product, a specific variation of a product, or a subscription product among others.

Let’s say you want to sell a one-year membership to a site. In this scenario, you can create a simple product for the membership plan, using the plan cost as the product price.

After you create the product, you can select the plan from the dropdown menu for products.

Now, you will need to determine how long the membership will last. You can choose a set period of states, a specific length of time, or you can make the membership indefinite.

3. Choose the content and products to restrict

After you complete the initial settings for the membership plan, you will need to choose which parts of your website to limit to members only.

To limit access to certain content, go to the Restrict Content section from the plan data tab. Next, click Add New Rule.

Choose the type of content and search for the name of what you want to restrict. With the Restrict Content tool, you can block access to posts, pages, categories, and tags.

If you want to drip the content to members, change the Accessible setting to specify a time. You can then choose how long to make new members wait before they can access the content.

Restricting products

Next, we will examine how to make products exclusive to your plan members. There are two ways to restrict products: viewing and purchasing.

With restricted viewing, only members have the ability to access the product detail page for the specified item. As a result, anyone who is not a member cannot see or purchase the item. With restricted purchasing, non-members can view the specified items but are unable to add them to their carts or complete an order.

To choose your exclusive products, go to Restrict Products. Leave the Type as Products and search for the product.

Use the Only members can dropdown to select the restriction type. Like restricting content, when barring access to products, you can choose to make the items available immediately upon sign up, or to delay access until the person has been a member for longer.

If you want to restrict an entire product category, select Product categories for Type and find the appropriate category.

The Memberships extension is compatible with several other WooCommerce extensions including Product Vendors. If you run a multi-vendor ecommerce store, you can restrict access to vendors based on the membership plan.

Go to Restrict Products and select the type Vendors. You can then select a vendor to make all their products available to members only.

With the Product Vendors extension, vendors are given a Customer or Subscriber role on your site. As such, they are unable to restrict their products or modify the details of your membership plan.

Adding a lock icon to restricted posts

To add the icon, we’ll filter the_title to adjust the post title. We’ll need to (a) be sure avoid running this in the WordPress admin, and (b) show this icon if access is restricted or delayed.

/**
 * Display a FontAwesome lock icon next to the post title if a member does not have access
 *  with WooCommerce Memberships.
 *
 * @param string $post_title the post title
 * @param int $post_id the WordPress post ID
 * @return string the updated title
 */
function sv_wc_memberships_add_post_lock_icon( $title, $post_id ) {

    if ( is_admin() ) {
        return $title;
    }

    // show the lock icon if the post is restricted, or access is delayed
    if (   ! current_user_can( 'wc_memberships_view_delayed_post_content',    $post_id )
        || ! current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) {

        $title = "<i class='fa fa-lock' aria-hidden='true'></i> {$title}";
    }

    return $title;
}
add_filter( 'the_title', 'sv_wc_memberships_add_post_lock_icon', 10, 2 );

That’s it ? Now, if a non-member views the site, any restricted post will show the lock icon + a title.

If a member logs in, they’ll see the normal title, or will still see a lock icon if they (a) can’t access the post, or (b) will be able to access it, just not yet:

This will only work for posts (or content Memberships treats like posts), not products, but the capabilities checks could be extended if you wanted to check other types of content.

View the full snippet here.

4. Set discounts and incentives for members

Discounts and other incentives make your membership plan more attractive to customers. With the WooCommerce Memberships extension, you can assign member-only discounts to items across your catalog.

Go to Purchasing Discounts. Select the items that you want to discount. You can assign promotions on an individual product level or to the category as a whole.

Discounts can be a percentage or a set dollar amount. After you finish setting up the membership discount, make sure to check Active to make it live on your site.

You can display a product’s discount by using the following shortcode: [wcm_product_discount]

This is a generic shortcode that returns the discount offered by all of your membership plans. You can modify the shortcode to include details for a specific plan by adding additional attributes. For example, [wcm_product_discount plan="123"]

Early access to content

Memberships makes it easy to restrict site content to members and to drip content based on how long someone has been a member. However, sometimes you may want to temporarily give early access to content to members, only making that content publicly available to non-members after some amount of time has passed.

There are any number of cases where that style of a content rollout could be valuable. A publisher with free and paid content might want to make the free content “members only” at first. A company that holds webinars could restrict speaker slides to members first. You might even want “early content access” to be a perk of membership that you use as a selling point.

Create an “early access” category

First, we’ll create a category for the posts and/or pages we want to temporarily restrict.

In this example, I’m calling the category Early Access. You can call this whatever you’d like, but keep an eye on the slug field here—we’ll need that later! (In this case, it’s early-access.)

Create early access category

Now we can apply the category to a post or page that we want to restrict to members only. Don’t worry, we’ll set up a way to automatically remove this category later when we’re ready for non-members to see this.

Create early access category

Grant access with your membership plan(s)

Next, we’ll need to restrict our Early Access category so it’s only accessible to our members. Here, I’ve created an Early Access Member plan and restricted our Early Access category to members of this plan. However, you don’t need to create a new membership plan specifically for early access to content (unless that fits your business model). You can give early access to members on any or all of your existing plans.

Add new membership plan

With this plan saved, our post is nonhidden from non-members. The message below can be adjusted in the WooCommerce Memberships settings so you can give non-members an idea of when the post will be available if they visit its page:

New Harry Potter Book Revealed

Remove access restrictions on a schedule

With members and non-members now seeing exactly what they are supposed to see, it’s time to add the bit of magic that removes the Early Access category from our posts—and, as a result, opens it up to non-members.

Note: You’ll need to make sure that you know how to add PHP to your site to do this. You could add this snippet to your custom child theme, create your own custom plugin, or use a plugin like Code Snippets to add your code.

The sv_wc_memberships_schedule_early_access_check function schedules the category removal event to run one week after the post is published. You can change +1 week to adjust the length of time to allow the members-only access. For example, you could change this to +3 days or +24 hours, depending on how long your non-members should wait for your exclusive content.

The sv_wc_memberships_remove_post_cat function removes the category, which makes the content available to everyone. If you’ve chosen a different name for your category, you’ll need to replace early-access with your category’s slug.

5. Set up the Members Area

Next, you will want to set up the Members Area for those in your plan. This is where users will go to see what their membership gives them access to. They can access the members areas from their account page.

You can set up the Members Area by going to the corresponding section of the Membership Plan Data tab.

There are five sections you can choose to enable for the Members Area:

  • Content: shows all pages and posts
  • Products: shows all products and categories that can be viewed or bought
  • Discounts: shows a list of products with membership discounts
  • Notes: shows any notes that have been emailed to the customer
  • Manage: shows the membership status and includes links to manage account

By default, all five sections of the Members Area are enabled. If you want to disable a certain section of the members area, click the box to remove it from the list.

6. Set up email reminders and customer communications

The final area of your membership plan you need to configure is the email content. The Memberships extension can send automated emails to members when there are any changes to their plans.

To enable these emails, you first need to go to WooCommerce > Settings > Emails to turn them on. In total, there are five messages you can enable. They are listed below:

After you enable the emails, you can return to your membership plan to customize the content of the messages.

You can customize the email using merge tags. For instance, you can use the tag and to add the user’s name. Or, you can use the tag to include a link to renew the membership.

7. Recurring billing with the WooCommerce Subscriptions extension

Predictable, recurring revenue is one of the biggest benefits of creating a membership plan for your WooCommerce store. If you want to collect a residual fee from your customers, you’ll need a way to charge recurring payments

The WooCommerce Memberships extension does not support recurring payments. However, it does integrate with the WooCommerce Subscriptions extensions which you can use to gain more flexible billing options for your members.

The process for setting up a recurring membership plan is straightforward. To start, you will need to create a subscription product using WooCommerce Subscriptions.

After you create the subscription product, you can go to the General section of your membership plan and select the subscription product as the method for granting access to the plan.

You’ll then need to specify the length of the membership. Choose subscription length to make the membership last as long as the paid subscription stays valid.

8. Managing your membership plan and members

Once you finish setting up all the settings for your plan, you can activate it by selecting Publish. If you want to wait to make the program live, select Schedule and choose a future launch date.

You can manage your plans by going to WooCommerce > Memberships > Membership Plans.

Managing members

As members start to sign up for your plans you can view and manage their profiles by going to WooCommerce > Memberships > Members.

You can manually add members by going to WooCommerce > Memberships > Members and clicking Add Member.

If the person already has an account for your WordPress site you can link their user account to a membership plan. If they are a new user, you will need to create a new user with an email address and name.

When you launch your membership program you may notice some customers purchased a product that would qualify them for a membership but did so before the plan was active. With the Memberships extension, you can use the purchase import tool to grant plan access to customers who bought items before the plan.

Adding new content and products

During the course of your business, you will inevitably create new content and products for your store. When you do, you will want to restrict access to some of this material.

With the Memberships extension, you can quickly add content to the membership plan straight from the page/post editor. Scroll to the Memberships tab and select the plans you want to add the content to.

When you add new products, you will see a similar meta box that you can use to include the item as part of a membership plan. You can also apply member discounts to products from the edit product page.

Help members renew with a different plan

By default, WooCommerce Memberships includes a “Renew” link for an expired membership. This allows the member to renew the membership by repurchasing the product (if available and at its current price) to resume the membership. This lets your member continue with any dripped content s/he already has access to once a set-length membership had expired if the member chooses to re-purchase.

However, we had a very interesting question recently: can you use this to provide an “upgrade” instead? For example, can you provide a 30-day “free” or “sample” membership, then use the renewal URL to prompt the member to purchase the one-year or “full” membership?

This is definitely possible with WooCommerce Memberships by changing the renewal URL so it doesn’t renew the current membership, but instead prompts the member to purchase a new one.

Change the Memberships Renewal URL

The renewal URL is filterable via the wc_memberships_get_renew_membership_url filter located in:
woocommerce-memberships/templates/myaccount/my-memberships.php

This will let us adjust the renewal URL, and it passes in the user membership object so we can do it conditionally based on the membership (such as which plan we’re looking at).

/**
 * Changes the renewal URL for the trial membership
 *
 * @param string $url the renewal URL
 * @param \WC_Memberships_User_Membership $membership the user membership
 * @return string $url the updated renewal URL
 */
function sv_change_renewal_url( $url, $membership ) {
    
    // Use the ID of the trial plan we should change the "renew" link for
    if ( 311 === $membership->plan_id ) {
        // Enter the ID of the membership product for the upgraded membership purchase
        // This add to cart link will change for variable products
        $url = '/checkout/?add-to-cart=569';
    }
    return $url;
}
add_filter( 'wc_memberships_get_renew_membership_url', 'sv_change_renewal_url', 10, 2 );

If you’ve never used an add to cart link with WooCommerce, this tutorial from Nicola Mustone is very helpful for both simple and variable product links.

When a member clicks the renew link now, that renew link will take them to the checkout with the upgraded membership product in the cart.

This is the only function that’s mandatory to change the renewal link for the trial membership to a link to purchase the upgraded membership. If you’d like to change this button text or delete the old membership, you can continue with additional snippets to refine this workflow.

Working with membership data

Filter WooCommerce Memberships export column headers

The first step in adjusting the member export is the ability to filter the column headers. This makes it possible to add, remove, or re-order columns in the export. This hook is available to modify headers:

apply_filters( 'wc_memberships_csv_export_user_memberships_headers', $headers, $export_instance );

Example 1: Remove unneeded headers

Let’s say you want to remove the membership plan ID and “has_access” columns. Doing so is simple, as you just need to remove the headers for these columns, and they won’t be output.

function sv_wc_memberships_modify_member_export_headers( $headers ) {

    // remove any unwanted headers
    unset( $headers['membership_plan_id'], $headers['has_access'] );
    return $headers;
}
add_filter( 'wc_memberships_csv_export_user_memberships_headers', 'sv_wc_memberships_modify_member_export_headers' );

That’s all it takes!

Example 2: Adding new headers

Adding headers is straight-forward as well:

function sv_wc_memberships_modify_member_export_headers( $headers ) {

    $headers['member_phone'] = 'member_phone';
    return $headers;
}
add_filter( 'wc_memberships_csv_export_user_memberships_headers', 'sv_wc_memberships_modify_member_export_headers' );

However, if you’re going to add a new header, you must also populate it with content.

Filter WooCommerce Memberships Export Column Content

If you want to add new columns to the file, you must also filter the column cell to populate it with the data for each member. We can do so with this hook:

apply_filters( "wc_memberships_csv_export_user_memberships_{$column_name}_column", '', $column_name, $user_membership, $export_instance );

This lets you adjust the data for that column. Notice that the filter name is dynamic — the $column_name will be replaced with the header name you’ve added. The $user_membership parameter is included and will let you get the user data you need.

For example, the user ID can be obtained with: $user_membership->get_user_id(), which can let you get the WP User data.

Let’s take our member_phone example above — we can now populate this cell using the wc_memberships_csv_export_user_memberships_member_phone_column filter (I’ve replaced the column name variable with the key I previously set).

function sv_wc_memberships_modify_member_export_columns( $data, $_, $user_membership ) {
    // return the data for this column
    return get_user_meta( $user_membership->get_user_id(), 'billing_phone', true );
}
add_filter( 'wc_memberships_csv_export_user_memberships_member_phone_column', 'sv_wc_memberships_modify_member_export_columns', 10, 3 );

Notice that I don’t have to scope this data to a particular column, as the filter name does that for me, so I can just return the data I need for the new column.

Adjust WooCommerce Memberships Exports: Putting it Together

Adding columns and removing them is pretty simple, so let’s put these together with a snippet that (1) removes some unwanted columns, (2) adds a new column in a specific position, and (3) adds the data for the new column.

We’ll remove a couple of columns, and insert the column for the member’s phone number (view snippet here):

/**
 * Modify the member CSV Export column headers.
 *
 * @param string[] $headers array of column headers as 'key' => 'output_name'
 * @return string[] updated headers
 */
function sv_wc_memberships_modify_member_export_headers( $headers ) {

    // remove any unwanted headers
    unset( $headers['membership_plan_id'], $headers['has_access'] );

    $new_headers = array();

    // add a column header for "member phone"
    foreach ( $headers as $key => $name ) {

        $new_headers[ $key ] = $name;

        // add our new header after the member email
        if ( 'member_email' == $key ) {
            $new_headers['member_phone'] = 'member_phone';
        }
    }
    return $new_headers;
}
add_filter( 'wc_memberships_csv_export_user_memberships_headers', 'sv_wc_memberships_modify_member_export_headers' );

/**
 * Adds data for our new member export column.
 *
 * Note that no column name check is needed since the filter name is scoped to the column key.
 *
 * @param string[] $data export data as 'column' => 'data'
 * @param string $_ unused, the column key
 * @param \WC_Memberships_User_Membership $user_membership User Membership object
 * @return string[] updated data
 */
function sv_wc_memberships_modify_member_export_columns( $data, $_, $user_membership ) {
    // return the data for this column
    return get_user_meta( $user_membership->get_user_id(), 'billing_phone', true );
}
add_filter( 'wc_memberships_csv_export_user_memberships_member_phone_column', 'sv_wc_memberships_modify_member_export_columns', 10, 3 );

Now some columns have been removed, and our new column is added after the “member email” column. This can allow you to add further user data, membership data, or plan data to member export files.

Translating a WooCommerce membership site

Navigate to the plugin folder on your web server (wp-content/plugins/woocommerce-memberships) and find a folder called i18n. (“i18n” stands for internationalization, because it starts with i, ends with n, and has 18 letters in between.) Clicking on the i18n folder shows another folder called languages. Clicking on that, you’ll see that there’s a file called woocommerce-memberships.pot.

A .pot file is a template on which all translations will be based. The woocommerce-memberships.pot file contains all the text used by the Memberships plugin. We recommend using the free Poedit app to open, edit, and insert your own translations in a .pot file.

Translating the text

Open Poedit and then select Create New Translation.

Create New Translation in Poedit.

Then, open up woocommerce-memberships.pot.

Next, select the language and locale for your translation. Let’s say you’d like to translate WooCommerce Memberships into French (from France, not Canada or any other variation). Select that language in the dropdown list. One selected, click on OK.

Select the language of the translation.

You’ll now see all the text strings from WooCommerce Memberships, then the (empty, for now!) translation section.

WooCommerce memberships

You can now start translating these strings. For example, Make a copy in French would be Faire une copie, so I typed that in the Translation box.

Adding a translation.

It’s important to note that Memberships has more than 1,000 strings of text to translate. You may not need to translate all of them. If all the site administrators are fluent (or proficient) in English, you may not want or need to translate strings related to the backend that are only visible to administrators.

Saving the file

Once you’ve finished translating, save the file using the plugin’s textdomain and the country and language code (known as the locale) for your specific version of that language. It’s important to include the textdomain, not just the locale default, so WordPress knows which plugin is affected by the translation.

I don’t want to save it just as this, which is the default in Poedit:

Don't just save a translation like this.

That wouldn’t work because I’m not using the textdomain to tell WordPress which plugin is being affected by this file.

So I need to first type in the textdomain. For WooCommerce Memberships, it’s woocommerce-memberships. You’ll also want to add a “” (hyphen) after the text domain to separate it from the locale. So your filename should look like this:

The proper save name of a translation.

If this translation were for French Canadian users, I’d save the file as woocommerce-memberships-fr_CA. (You can find more about locales here.) Note: It’s important that the locale matches your Site Language in WordPress.

Site languages.

The file you’re saving from Poedit should end in .po, so we should be saving it as woocommerce-memberships-fr_FR.po and it’ll automatically generate a woocommerce-memberships-fr_FR.mo to go along with it. You’ll need both of those files for the translation to be visible on your site. (Here’s a summary of the differences between .pot, .po., and .mo files, if you’re curious.)

Where to save the files

You can save the files in the same spot you found the .pot file, so for our WooCommerce Memberships example, this would be in:

wp-content/plugins/woocommerce-memberships/i18n/languages/

However, this has the possibility of being replaced when you update your plugin and that file could be overwritten in a future update! As such, you may want to keep all your translations in:

wp-content/languages/plugins/

Because you’re using the plugin’s textdomain and locale, WordPress knows when to use the .po file you created and the .mo file that was generated for it, even if they’re not in the plugin’s folder.

Conclusion

A thoughtful membership program with WooCommerce can be a valuable tool for rewarding your most loyal customers. They can enjoy exclusive discounts and products while you get to benefit from lower churn rates and better customer retention. If you have been looking for new ways to engage your audience consider using WooCommerce to create a membership plan with plenty of useful benefits.