Page 1 of 1

Limit the number of members...

PostPosted: May 30th, 2010, 12:15 am
by ryannagy
I should probably try to figure this out before posting...BUT..I want to limit one of my membership levels to a certain number. For example, I may have a level that gets to have a monthly coaching webinar with me at $99 or something, but want to limit that group to 10 people (or similar).

Cheers - Ryan

Re: Limit the number of members...

PostPosted: June 2nd, 2010, 4:06 am
by Elizabeth
Thanks for the great suggestion. You might want to send an email directly to Jason for a quote:
http://www.primothemes.com/support/

Re: Limit the number of members...

PostPosted: June 23rd, 2010, 8:16 pm
by Jason Caldwell
Hi, I don't think this is a feature that will make it into the official release of s2Member. It's a fairly uncommon request; from what I've seen. That being said, it's definitely do-able. You'll just need to wrap your Button Code inside Advanced Conditionals. You'll probably want to get a freelancer to help you with the scripting.

Re: Limit the number of members...

PostPosted: September 17th, 2011, 9:36 pm
by lmllewellyn
Did anything ever come of this request? I would also like to limit my groups to 10 (or so) members.

Thanks,
Lisa

Re: Limit the number of members...

PostPosted: September 18th, 2011, 1:18 am
by antseo
I would be interested as well in this feature.

Re: Limit the number of members...

PostPosted: September 20th, 2011, 6:13 pm
by Jason Caldwell
Thanks for the votes on this feature.

Nothing integrated into s2Member in this regard yet. For now, I'll provide a code sample that you might find useful. In order to use this, you will need to have the PHP Execution plugin installed first, so that PHP tags are parsed in your Posts/Pages.

Code: Select all
<?php
if 
(count (get_users ("role=s2member_level1")) >= 10)
    {
?>
        Sorry, we are no longer accepting Membership signups.
<?php
    
} else {
?>
        [s2Member-PayPal-Button .. /]
<?php
    
}
?>
* See also: http://codex.wordpress.org/Function_Reference/get_users
Other Roles include: subscriber, s2member_level1, s2member_level2, etc.

Re: Limit the number of members...

PostPosted: September 20th, 2011, 6:19 pm
by antseo
thanks Jason!

Re: Limit the number of members...

PostPosted: January 4th, 2012, 11:38 am
by lmllewellyn
Thanks for this code. How would I limit the number of people with a certain custom capability. Is this also possible?

Re: Limit the number of members...

PostPosted: January 5th, 2012, 1:20 am
by Jason Caldwell
lmllewellyn wrote:Thanks for this code. How would I limit the number of people with a certain custom capability. Is this also possible?
Something like this perhaps.
Code: Select all
<?php
global $wpdb
;
$ccap = "music";
if(
count($wpdb->get_results("SELECT `user_id` as `ID` FROM `".$wpdb->usermeta."` WHERE `meta_key` = '".$wpdb->prefix."capabilities' AND `meta_value` LIKE '%\"access_s2member_ccap_".esc_sql($ccap)."\"%'")) >= 10)
    {
?>
        Sorry, we are no longer accepting Membership signups.
<?php
    
}
else
    {
?>
        [s2Member-PayPal-Button .. /]
<?php
    
}
?>

Re: Limit the number of members...

PostPosted: January 5th, 2012, 5:45 pm
by lmllewellyn
Thanks so much, Jason. The count statement isn't quite right (it comes out at 0 even though I know several people have my defined custom capability) - but this will work if I can figure out what's wrong with it. Does someone want to quote me a price to get this php Select statement just right?

Re: Limit the number of members...

PostPosted: January 5th, 2012, 7:14 pm
by peeld
Just wanted to get in on this topic, limiting the number of people who can have a ccap is something I'm interested in, want to get email updates to this topic :)

Re: Limit the number of members...

PostPosted: January 11th, 2012, 3:20 pm
by peeld
I'll chime in with lmllewellyn and will pay as well ;)

Re: Limit the number of members...

PostPosted: January 14th, 2012, 8:58 pm
by Jason Caldwell
Thanks for the follow-ups.
I just tested this again. I can confirm that this code does work as expected.
Jason Caldwell wrote:
lmllewellyn wrote:Thanks for this code. How would I limit the number of people with a certain custom capability. Is this also possible?
Something like this perhaps.
Code: Select all
<?php
global $wpdb
;
$ccap = "music";
if(
count($wpdb->get_results("SELECT `user_id` as `ID` FROM `".$wpdb->usermeta."` WHERE `meta_key` = '".$wpdb->prefix."capabilities' AND `meta_value` LIKE '%\"access_s2member_ccap_".esc_sql($ccap)."\"%'")) >= 10)
    {
?>
        Sorry, we are no longer accepting Membership signups.
<?php
    
}
else
    {
?>
        [s2Member-PayPal-Button .. /]
<?php
    
}
?>

Re: Limit the number of members...

PostPosted: January 16th, 2012, 1:01 pm
by peeld
Bugger all, the PHP Execution plugin doesn't work - just returns the code. Know of any other trustworthy plugins that allow for the PHP code to execute?

Re: Limit the number of members...

PostPosted: January 16th, 2012, 1:05 pm
by Jason Caldwell

Re: Limit the number of members...

PostPosted: January 16th, 2012, 1:31 pm
by peeld
That works, sweet :)

Re: Limit the number of members...

PostPosted: January 16th, 2012, 6:18 pm
by lmllewellyn
AWESOME!! It works with the Exec-PHP plugin. Thanks so much!