Hello,
I want to limit registrations on my site to create artificial scarcity. How can I redirect guests to another page when my site membership hits 5,000 members.
1. Site reaches 5,000 registered members
2. Guests trying to access buddypress registration page after attaining 5,000 members are automatically redirected to another custom page with url slug (sign-up-closed)Thanks
Thanks for the reply but I dont really know how to code and how to check for the conditions
The conditons needed are
1. User must be a guest or logged out
2. Total site members must be 5,000
3. redirect to page with ID 45565Thank you
- This reply was modified 4 years, 7 months ago by Tosin.
Hello Tosin,
Please try the following code. It will redirect new users to page with id ‘45565’
add_action( 'bp_template_redirect', function () { // If logged in nothing to do with it. if ( is_user_logged_in() || ! bp_is_register_page() ) { return; } $site_users = get_users( array( 'fields' => 'ID' ) ); $site_users_count = count( $site_users ); // If site user count is less than 5000 not need to redirect. if ( 5000 > $site_users_count ) { return; } // Check your conditions here. home_url to you page url. bp_core_redirect( get_page_link( 45565 ) ); } );
Please let me know if it works or not. One more question, Are you working with multisite then there will be a slight change?
Regards
Ravi
You must be logged in to reply to this topic.