Pro Site free trial without payment agreement first

I want to offer a free trial on a Pro Site level without the member being prompted to a payment agreement in Stripe and Paypal first. Ideally, the member would register and get a free trial for a level, then once the trial is nearing its end, they would *then* be prompted to enter payment. I need to know what code/tables I would need to alter to make this possible.

  • Ivan

    Hi leoventans !

    Unfortunately, it's not available out of the box but you can use the following trick.
    You could try adding the following snippet in a MU plugin ( more info about MU plugins is here )

    <?php
    function wpmu_prosites_change_logic_free_trial( $content, $blog_id, $domain ) {
    	if ( class_exists( 'ProSites_Helper_Session' ) ) {
    		$activation_key = ! empty( $_POST['activation'] ) ? $_POST['activation'] : ProSites_Helper_Session::session( 'activation_key' );
    		global $wpdb;
    		$signup_details = $wpdb->get_row( $wpdb->prepare( "SELECT <code>domain</code>, <code>path</code>, <code>active</code> FROM $wpdb->signups WHERE activation_key = %s", $activation_key ) );
    
    		if ( $signup_details && ! empty( $activation_key ) && !$signup_details->active ) {
    
    			$domain = $signup_details->domain;
    			$path   = $signup_details->path;
    
    			if ( class_exists( 'BuddyPress' ) ) {
    				// Set up activation link
    				$activate_url = bp_get_activation_page() . "?key=$activation_key";
    			} elseif ( ! is_subdomain_install() || get_current_site()->id != 1 ) {
    				$activate_url = network_site_url( "wp-activate.php?key=$activation_key" );
    			} else {
    				$activate_url = ! empty( $path ) && ! empty( $domain ) ? "http://{$domain}{$path}wp-activate.php?key=$activation_key" : '';
    			}
    			$activate_url = esc_url( $activate_url );
    			if ( $activate_url ) {
    				wp_redirect( $activate_url );
    				exit;
    			}
    		}
    	}
    	return $content;
    }
    add_filter( 'prosites_render_checkout_page', 'wpmu_prosites_change_logic_free_trial', 10, 3 );
    
    function wpmu_not_extend_manual( $blog_id, $user_id, $password, $signup_title, $meta ) {
    	$last_gateway = class_exists( 'ProSites_Helper_ProSite' ) ? ProSites_Helper_ProSite::last_gateway( $blog_id ) : '';
    	if ( !empty( $meta['pro_site_manual_signup']['gateway'] ) && 'manual' === $meta['pro_site_manual_signup']['gateway'] && 'trial' === $last_gateway ) {
    		global $psts;
    		remove_action( 'wpmu_activate_blog', array( $psts, 'process_manual_signup' ) );
    	}
    }
    add_action( 'wpmu_activate_blog', 'wpmu_not_extend_manual', 9, 5 );

    Then you can enable Manual Payments (WP Dashboard -> Pro Sites -> Payment Gateways -> Manual Payments), set Show Submission Form setting as NO and add this gateway as Secondary gateway on WP Dashboard -> Pro Sites -> Payment Gateways -> Gateway Settings page.
    After that, your user can create Pro sites with Alternate Payment.

    Note: this text can be changed on WP Dashboard -> Pro Sites -> Payment Gateways -> Gateway Settings page.

    Best,
    Ivan.

  • leoventans

    Hi Ivan,
    many thanks for your solution.

    But after I add this code it will stuck , when I filled the signup form it will show "Processing..." and no more response.

    Actually I want to create custom signup form and user no need to payment first and the site will got the lowest level and free trial days.

    This is my idea, create function when user signup the site and insert data to "wp_pro_sites" "level", "expire", "gateway"...

    Is it possible to achieve? or there are others tables I need to insert data?

    Thanks for help!!

  • Ivan

    Hi leoventans !

    This is my idea, create function when user signup the site and insert data to "wp_pro_sites" "level", "expire", "gateway"...

    Yeah, you can try to do it. You can use the extend function in ProSites class for that.({wordpress_folder}/wp-content/plugins/pro-sites/pro-sites.php file, 2068th line)
    For instance :

    global $psts;
    $psts->extend($blog_id, $period, $gateway, $level_id, $amount, $expires);

    But after I add this code it will stuck , when I filled the signup form it will show "Processing..." and no more response.

    If you want to investigate it, please, provide me with additional login credentials, I can look into it more.

    https://premium.wpmudev.org/contact/#i-have-a-different-question
    Please visit our private Contact page and complete the form with the following information:

    Subject: "Attn: Ivan Svyrskyi"

    In the Message box, please provide the following:

    - link back to this thread for reference
    - any other relevant urls

    - Admin login:
    Admin username
    Admin password
    Login url

    - FTP/SFTP credentials
    host
    username
    password
    (and port if required)

    Note: Don't send any credentials via this forum because it's public forum.

    Best,
    Ivan.

  • Joseph

    I too am trying to achieve this. All of my competitors let their users sign up for a free 14 day trial. As their trial is nearing the end, the user receives emails notifying them that the end of the trial is near with a link to pick a plan and pay. This is pretty common practice as many sites offer this. When will this be part of Pro Sites?

    @ leoventans , have you been able to figure this out yet?