Page 1 of 1

Free Registration @ Different Levels

PostPosted: October 2nd, 2010, 12:11 pm
by Jason Caldwell
s2Member deals with Levels [0-4]. These Levels are detected automatically during Registration. In other words, the Registration Form is adjusted automatically, based on the Level that a Customer purchases access to. As of s2Member v3.2.7+, you can also configure Custom Fields at different Levels, so the Registration Form will change in appearance if/when you have different Fields configured.

Now, if it's a free Registration, s2Member always defaults to Level # 0 ( a Free Subscriber ). So this works perfectly. However, in some cases, you may wish to offer Free Membership at multiple/different Levels, instead of Level #0 by itself. Since s2Member expects Levels 1-4 to be "paid for", you will have to link to the Registration Form in a more "advanced way" if you intend to offer these Levels [1-4] for free.

You can use this function to create a link that will allow "Paid Registration Access" for "Free" instead of requiring a Customer to go through PayPal®. This same function is often used by other gateways providers that intend to interface with s2Member, so you can adapt this to your situation; as needed.

Code: Select all
$link = ws_plugin__s2member_register_link_gen
($subscr_id, $custom, $item_number, $shrink);  

$subscr_id = the paid transaction ID, or just a dash (-) if there was no transaction.
$custom = $_SERVER["HTTP_HOST"] ( must match the domain hosting the s2Member installation )
$item_number = 1,2,3 or 4 ( the Level number that a Customer will go in as during registration )
$shrink = ( false ) return the URL in full format, or ( true / return a tinyURL for emailing ).


Sending a Customer to the link produced by this function, will ultimately set three encrypted cookies, that s2Member will read in automatically, and ALLOW registration temporarily ( one time ).

Additional details ( optional ).

$item_number could also include
Custom Capabilities, and/or a fixed term length.

$item_number = 1,2,3, or 4
-- OR --
$item_number = level:custom capabilities:fixed term
( ex: 1:music,videos:1 M )

Which means:
Level #1 access, + music,videos as Custom Capabilities - account expires in 1 month.

Re: Free Registration @ Different Levels

PostPosted: October 2nd, 2010, 12:11 pm
by Jason Caldwell
Here is more of a real-world example of how this might be implemented on your site.
Inside the functions.php file for your WordPress® theme, insert a snippet like this:
Code: Select all
add_action("init""register_level");
function 
register_level(){
    if(
$_GET["register_level"]){
        
$link ws_plugin__s2member_register_link_gen ("-"$_SERVER["HTTP_HOST"], $_GET["register_level"], false);
        
wp_redirect($link);
        exit;
    }
}   

Here are how the actual links would be formulated:
Code: Select all
http://example.com/?register_level=1
http://example.com/?register_level=2
http://example.com/?register_level=3
http://example.com/?register_level=4

Re: Free Registration @ Different Levels

PostPosted: October 5th, 2010, 2:52 pm
by jhg03
How would I work that into the paypal-pro-registration-form.html file (to register for free as a level 4 member)?

Thank you!

Re: Free Registration @ Different Levels

PostPosted: November 30th, 2010, 4:28 am
by x3000gold
Hi,

This solved my problem! Im sooo glad :)

Re: Free Registration @ Different Levels

PostPosted: November 30th, 2010, 6:14 am
by SantiAzpi
Wow, I am impressed, Jason! After months of playing with WP, I finally begin to get how hooks work...

Very good example, thank you!

Re: Free Registration @ Different Levels

PostPosted: December 12th, 2010, 3:37 pm
by x3000gold
When I use WP Super Cashe this do not work any more. Is there any way around this?

Please help me!

Re: Free Registration @ Different Levels

PostPosted: February 15th, 2011, 5:15 am
by stowe39
I am trying to set up s2 member on my test webserver with levels 1,2,and 3 as paid levels and have level 4 function as a "free 1 day trial"

I've changed the code in functions.php to

Code: Select all
add_action("init", "register_level");
function register_level(){
  if($_GET["register_level"]){
    $link = ws_plugin__s2member_register_link_gen ("-", $_SERVER["HTTP_HOST"], "4:1D", false);
    wp_redirect($link);
    exit;
  }
}


and the link in wp is
Code: Select all
http://localhost/wordpress/?register_level=4


But when I sign up a test user, they show up as a "subscriber" in the users list instead of as a "S2Member Level 4"

I think I've got a syntax error in function register_level() code.... does anyone know how to code it so it works?

Thanks

Kym