I saw Pro-Sites recommend to automate the new site creation

I saw Pro-Sites recommend to automate the new site creation process for paid members and I believe a free or trial membership.

What if I want to allow free site creation for employees of one particular company?

Could I use pro-sites and configure it so it removes any reference to required memberships or payments?

Then I saw a plugin to require a code as signup & maybe I use that to provide to all employees of that company so only they could create an account?

Or would there be a better way to restrict access for new site creation if the user/employer is not paying but rather the employer pays for one fee for all accounts?

Thanks!
-George

  • aristath

    Hello there @George, I hope you're well today!

    I've never seen an implementation like this before, but you should be able to do it with some custom code.
    You will need to do the following:
    1. Add a custom field to the user profiles. That's where users will be able to add a value (for example their company name, or a code or whatever). You can create new profile fields using this plugin: https://wordpress.org/plugins/cimy-user-extra-fields/
    2. After you add that field, you can then paste the below code in a new php in your wp-content/mu-plugins folder (if that folder does not exist, you should manually create it).

    <?php
    
    function my_custom_prosites_override() {
    
    	// The level we want to assign our sites to
    	$level = 3;
    
    	// The user profile field to check
    	$field = 'my_field';
    
    	// The value of the profile field that will trigger the level upgrade
    	$value = 'field_value';
    
    	$blog_id   = get_current_blog_id();
    	$pro_sites = new ProSites();
    
    	$current_user = wp_get_current_user();
    	// Do not proceed if the current user is not an admin.
    	if ( ! $current_user->has_cap( 'manage_options' ) ) {
    		return;
    	}
    
    	// Do not proceed if the user doesn't have a valid value on their profile field
    	$profile_fields = get_the_author_meta( $current_user->ID );
    	if ( $value != $profile_fields[$field] ) {
    		return;
    	}
    
    	// Do not proceed if the current site is already on the level we want.
    	if ( $level == $pro_sites->get_level( $blog_id ) {
    		return;
    	}
    
    	// Extend the site
    	$pro_sites->extend( $blog_id, 9999999999, false, $level )
    
    }
    add_action( 'wp', 'my_custom_prosites_override' )

    You will of course have to edit the 'my_field' and 'field_value' above to what you're using, but that should work...
    What the above does is the following:
    1. Checks if the current user is an admin. If he is, then proceeds to the next test.
    2. Checks if the current user's profile field has the value you have specified. If they do, then continues to the next test.
    3. Checks if the site is already on the pro-sites level you have specified (in the above example. 3). If it is not, then proceeds to changing it
    4. If all the above tests have passed, then the pro-sites level is extended and is assigned the level you have specified.

    I hope that helps!

    Cheers,
    Ari.

  • George

    Thank you and I have another related question please. On the 2nd video for Pro-Sites at about 2:00 it shows the edublogs sign up page and mentions that you can use another wpmudev plugin to let users choose their own password, which plugin would that be?

    It then explains how they can choose their own blog domain & title and install a captcha. I went through all the tutorials but missed anything relating to how to setup that signup page. Where could I find that info so I could setup a similar signup page if possible?

    Can we setup a pages similar to http://edublogs.org/signup/

    thanks again!!

  • Michelle Shull

    Hey there, George!

    I watched the video, but I'm not seeing the part you're speaking of here. As far as I know, we don't have a plugin for choosing a password on signup.

    What we can do, however, is fix up your wp-signup page a bit. Edublogs has several hundreds of hours of custom work, but we can make your signup page work a bit more like Edublogs.

    First up, make sure users can create both usernames and sites on the signup page. This is set in your network admin dash, under Network Settings.

    That option allows users to pick their domain/blog name will show up on the second signup page. The first page just asks for a name and an email address, as well as a choice between just a user name, or a user name and a site.

    To add a CAPTCHA, you can use our Anti-Splog plugin, which protects you from spam users overrunning your blogroll, and let's you add an extra level of protection on your sign up form.

    Hope this helps!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.