latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Delete Free Members (S2Member Level0)

Home Forums Community Forum Delete Free Members (S2Member Level0)

This topic contains 4 replies, has 2 voices. Last updated by  Robert Funge 3 years, 11 months ago.

Topic Author Topic
Posted: Wednesday Jan 30th, 2013 at 8:16 am #39999
Robert Funge
Username: godrob

Hi guys,

Could any of you help me out with this please? I run a WordPress/BuddyPress community with S2member at the heart of things handling membership upgrades/downgrades etc. Members subscribe at Level1 where I give them a free 14 day trial of our site. They can upgrade at anytime during the 14 days to Level2 and beyond (Premium Membership). I’m using S2Member PayPal Pro Forms, and all of this works really well.

The issue I have is that roughly half of my Subscribers never actually upgrade to a Premium Membership, and so after their 14 day trial is over, they never return. This leaves a lot of Subscribers clogging up my site at Level0 (Free Members).

So my question therefore is, is there a hack or a SQL command that I can use to automatically delete Free members – S2Member Level0 who haven’t logged in or been active for a given period of time, say 6 months or so?

Would appreciate any help here…

Thanks
Rob.

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Saturday Feb 2nd, 2013 at 4:16 am #40339
Staff Member

Thanks for your inquiry. ~ We appreciate your patience :-)

This would require custom code if you don’t want to do it from the Dashboard.
I’ll try to point you in the right direction.

Please create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
(NOTE: these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins)
(See also: http://www.s2member.com/kb/hacking-s2member/)

<?php
add_action('init', 's2_delete_old_subscribers');
function s2_delete_old_subscribers()
	{
		if(empty($_GET&#91;__FUNCTION__&#93;)) return;
		
		foreach(get_users('role=subscriber') as $user)
			if(strtotime($user->user_registered) < strtotime('-6 months'))
				wp_delete_user($user->ID);
		
		exit('Old Free Subscribers deleted.');
	}

Now open this URL in your browser.

http://www.example.com/?s2_delete_old_subscribers=yes
BACKUP YOUR DATABASE BEFORE RUNNING THIS CODE.
Posted: Wednesday Feb 6th, 2013 at 8:10 am #40902
Robert Funge
Username: godrob

Hi Jason, Many thanks for taking the time to code this. It’s appreciated.

Two questions. I’m using Buddypress, so will –

wp_delete_user($user->ID);

be sufficient to delete users cleanly on BuddyPress to?

Secondly, does the code take into account when the user last logged into the site? Ideally, I only want to delete members who are on level0 and haven’t logged in for 6 months or more. I do not want to delete everyone who has been at Level0 for longer than 6 months. Only those who have been inactive, if that makes sense?

We have free members at level0 still using non premium features of our site and I obviously don’t want to delete them :)

Is this possible?

Thanks again
Rob.

Posted: Thursday Feb 7th, 2013 at 7:33 pm #41116
Staff Member

Two questions. I’m using Buddypress, so will –

wp_delete_user($user->ID);
be sufficient to delete users cleanly on BuddyPress to?

I’m not aware of any problems with this function when running BuddyPress. However, this is a question that I would ask in the BuddyPress forums for some confirmation.

Secondly, does the code take into account when the user last logged into the site?

s2Member® does not keep track of this information yet; and neither does WordPress® to my knowledge. So it’s going to be very difficult to implement this. s2Member® keeps track of the number of times that a User/Member has logged in, but not the times at which this occurred. I’ll accept this as a feature request though.

Posted: Friday Feb 8th, 2013 at 5:20 pm #41224
Robert Funge
Username: godrob

Hi Jason,

Yes, please if you could add it as a feature in an upcoming release that would be awesome…

Thanks
Rob.

Viewing 4 replies - 1 through 4 (of 4 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.