Assign user to subscription level upon registration

Hi,

For my free subscription level I would like to skip the "subscribe" page/step that appears upon successful registration as it's a useless step and interrupts the flow of the site.

I know this is a custom job, but could you please point me in the direction as to which database tables need to be altered upon registration, and which plugin files I should be looking at. Seems like "/classes/membershippublic.php/" is a good starting point?

Thanks

  • Louise

    Hi Vaughan,

    Thanks for your help!

    I've just realised that upon free user registration, the next page shown looks like this |(ignore styling):
    http://dl.dropbox.com/u/120937783/Screenshots/Screen%20Shot%202013-10-02%20at%2000.50.57.png

    So it appears that on free registration user is getting added successfully and subscription etc is in fact being set up. So the question is, how do I add a redirect instead of posting back to register page in the case of it being a free registration on <sub X>?

    Thanks!

  • Louise

    Update: Found a solution - not sure how stable it is.

    My solution is as follows:

    File: /membershipincludes/classes/membershippublic.php

    Roughly around lines 1600-1700, I'm not sure (I've added a fair bit of my own lines so cannot be accurate). I changed this:

    // Hack for now - eeek
    $anyerrors = $error->get_error_code();
    if( !empty($anyerrors) ) {
    	// we have an error - output
    	// Show the page again so that it can display the errors
    	$content = $this->output_registeruser( $error );
    
    } else {
    	$content = $this->output_paymentpage( $user_id );
    }

    To this:

    // Hack for now - eeek
    $anyerrors = $error->get_error_code();
    if( !empty($anyerrors) ) {
    	// we have an error - output
    	// Show the page again so that it can display the errors
    	$content = $this->output_registeruser( $error );
    
    } else {
    	if ( $_REQUEST['subscription'] ) {
    		if ( $_REQUEST['subscription'] == 2 ) {
    			wp_redirect( '/my-account' );
    			exit;
    		}
    	} else {
    		$content = $this->output_paymentpage( $user_id );
    	}
    }

    Where subscription with Id=2 is my free subscription.

    Would be great if someone could point out any potential pitfalls with this solution. My members do not need to be able to upgrade/downgrade plans - each plan is specific to a demographic so a subscriptions page is not necessary for the use case of upgrading etc.

    Thanks

  • Louise

    Hi Vaughan

    Yeah good find. I did this initially so I could act conditionally based on which subscription is set and redirect accordingly.

    What you suggested is not only a better solution (thanks!) but also a necessary solution.

    My version was not working for paid subscriptions the conditional else wasn't giving subscription payment a chance.

    Anyway, here's what is working for me at the moment:

    // Hack for now - eeek
    $anyerrors = $error->get_error_code();
    if( !empty($anyerrors) ) {
    	// we have an error - output
    	// Show the page again so that it can display the errors
    	$content = $this->output_registeruser( $error );
    
    } else {
    	if ( ( $_REQUEST['subscription'] ) && ( $_REQUEST['subscription'] == 2 ) ) {
    		wp_redirect( '/welcome' );
    		exit;
    	} else {
    		$content = $this->output_paymentpage( $user_id );
    	}
    }

    Thanks again, Vaughan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.