mermberfix logo x
The MemberFix Team’s got you covered.
Membership plugins

How to bulk delete MemberMouse expired members

membermouse bulk delete

Introduction

Overview

Many of our MemberFix customers use MemberMouse as the main solution for their WordPress membership websites. One of the situations I’ve encountered is when a customer requests to delete ALL of their “Expired” MemberMouse members.

However, this cannot actually be done within the WordPress admin area because MemberMouse has some restrictions around deleting members. In this case, if they have access to any memberships or bundles you have to delete that access first before you can remove the member. This is cumbersome to do on a large scale as you’d essentially need to do it member-by-member.

Luckily, I was able to come with a solution!

The problem of bulk deleting the “Expired” MemberMouse members

Let’s go to WordPress and then to MemberMouse > Manage Members.

Next in the Search form select “Expired” from the top right Membership Status and click on the “Show Members” button.

membermouse expired members - How to bulk delete MemberMouse expired members

You will be able to see a list of all “Expired” members.

But when you try to perform a bulk delete you will notice that this cannot be done and, more than this, you are not even able to delete the members one by one without first removing all of their access! (And again, that would not be a great option if you have hundreds of “Expired” members).

When you mouse over the delete member icon you will see the following message: “This member has an active paid membership or bundle which must be canceled before they can be deleted”.

 

member mouse member delete - How to bulk delete MemberMouse expired members

The solution: using SQL queries

The solution to solve this problem and be able to perform a bulk delete for all these “Expired” members was to use SQL queries.

How can you use the SQL queries on your hosting service? That is pretty easy.

An important note: make sure that the expired members you’re deleting have NO active subscriptions of any kind. The expired status in MemberMouse doesn’t mean that an active paid subscription is no longer active and charging the member’s payment method. Rather, it means that a member’s access to content has expired.

So a member can be paying but not have access to content and you want to make sure you’re not creating headaches for yourself by deleting members who are paying you but just not getting access to content at the moment. If you’re certain that the expired members are no longer being charged, you can proceed with deleting them using the method I’m going to show you below.

Use SQL queries on Cloudways

If your website is hosted on Cloudways please login to your account, click on top Applications link and then click on the listed link for your website.

cloudways database manager - How to bulk delete MemberMouse expired members

After that you will land on “Access Details” page. Please click on “Launch Database Manager” and after the new page loads please click on SQL command link.

cloudways sql command - How to bulk delete MemberMouse expired members

You will land on the page where you will be able to add the SQL query and then click on “Execute” button.

sql command execute - How to bulk delete MemberMouse expired members

Use SQL queries on cPanel

If you have a host which uses cPanel then all you have to do is to login to your account and then click on “phpMyAdmin” under “Databases” section.

phpmyadmin cpanel - How to bulk delete MemberMouse expired members

Click the database name on the left side and then on top “SQL” link.

sql cpanel - How to bulk delete MemberMouse expired members

The SQL queries

Now that we have everything ready it’s time to add the queries.

IMPORTANT! Before performing any of the below SQL queries please create a backup for your database!

1 – The first SQL query which we will use it will generate a list of comma separated users ID-s. We will need this list for the next queries.

The SQL query is:

SELECT GROUP_CONCAT(wp_user_id)
FROM `mm_user_data` WHERE `status` = 8
order by `last_name`;

You might wonder what is that number 8 for the status. Well, that is the number which MemberMouse use to indicate the “Expired” members. Here are all these numbers used for status: 1 (Active), 2 (Canceled), 3 (Locked), 4 (Paused), 5 (Overdue), 6 (Pending Activation), 7 (Error), 8 (Expired), 9 (Pending Cancellation).

The generated list will be something like: 7,15,16,18,23,25… etc

2 – The second SQL query is to delete all these members from mm_user_data table:

DELETE FROM `mm_user_data`
WHERE `status` = 8

3 – Delete users from mm_custom_field_data table:

DELETE FROM `mm_custom_field_data`
WHERE `user_id` IN
(7,15,16,18,23,25…) ;

Of course, instead of the above numbers, just use the list you have previously generated.

4 – Delete users from mm_log_events table:

DELETE FROM `mm_log_events`
WHERE `user_id` IN (7,15,16,18,23,25…) ;

5 – Delete users from mm_orders table:

DELETE FROM `mm_orders`
WHERE `user_id` IN (7,15,16,18,23,25…) ;

6 – Delete users from mm_order_item_access table:

DELETE FROM `mm_order_item_access`
WHERE `user_id` IN (7,15,16,18,23,25…) ;

7 – Delete users from mm_scheduled_payments table:

DELETE FROM `mm_scheduled_payments`
WHERE `user_id` IN (7,15,16,18,23,25…) ;

8 – And finally we need to delete all these “Expired” MemberMouse members from wp_users table too:

DELETE FROM `wp _users`
WHERE `ID` IN (7,15,16,18,23,25…) ;

That is all!

We have got rid of all those “Expired” members. Needless to say that if, for example, you want to delete all “Canceled” members you will just need to replace 8 with 2 for “status” on steps 1 and 2.

Please let me know if you have any questions or suggestions.

 

You may also enjoy...

WordPress based membership sites have certain requirements, and make use of certain applications that, in my experience, makes most of the popular hosting providers a poor choice.
This post shows you a step-by-step procedure for adding content upgrades to your content using ThriveLeads and Drip. Read more…
Learn how to change the color and style of the password strength meter on the MemberPress checkout registration form.
This tutorial will show you how to create a multi-step popup optin form with GravityForms and Divi and connect it to your email marketing app.
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Steven
February 25, 2022 2:00 pm

What about wp_usermeta? I assume you also need to run DELETE FROM wp_usermeta WHERE user_id ?..