PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Multiple Registration Forms

s2Member Plugin. A Membership plugin for WordPress®.

Multiple Registration Forms

Postby cjay175 » January 23rd, 2011, 5:47 pm

Hi there,

First off like to thank for the awesome plugin, I can't believe how well this plugin is made - great job.

I am trying to create a multiple registration area. I noticed that S2member has custom registration fields and have the ability to have these custom fields show up only for certain levels.

I am wondering is it is possible to change this feature from levels to say a custom user meta.

So the fields would show up when a user has a meta type of "renter" or "landlord".

I have so far been able create custom fields with the avialable for "renter" or "landlord" instead of 1,2,3,4,0 or all.

Now I am trying to get them to show up and have found this in custom_reg_fields_inc.php

Code: Select all
if (!function_exists ("ws_plugin__s2member_custom_fields_configured_at_level"))
   {
      function ws_plugin__s2member_custom_fields_configured_at_level ($_level = "auto-detection")
         {
            eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
            do_action ("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars ());
            unset ($__refs, $__v); /* Unset defined __refs, __v. */
            /**/
            $level = ($_level === "auto-detection") ? ws_plugin__s2member_user_access_level () : $_level;
            if ($_level === "auto-detection" && $level < 0 && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($cookie = ws_plugin__s2member_decrypt ($_COOKIE["s2member_level"]))))
               list ($level) = preg_split ("/\:/", $cookie, 3);
            /**/
            $level = (!is_numeric ($level) || $level < 0) ? 0 : $level; /* Always default to Level #0. */
            /**/
            if (is_numeric ($level) && $level >= 0 && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
               {
                  foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
                     if ($field["levels"] === "all" || in_array ($level, preg_split ("/[;,]+/", preg_replace ("/[^0-9,]/", "", $field["levels"]))))
                        $configured[] = $field["id"]; /* Add this to the array. */
               }
            /**/
            return apply_filters ("ws_plugin__s2member_custom_fields_configured_at_level", $configured, get_defined_vars ());
         }
   }


How would I go about change this to show depending on the words of "renter" or "landlord".

I know this might be a little over the top for a simple question and would be willing to pay or listen to any other ideas for creating 2 seperate registration pages. Each user type has different info to fill out during registration.

Thanks for any help
User avatar
cjay175
Registered User
Registered User
 
Posts: 2
Joined: January 23, 2011

Re: Multiple Registration Forms

Postby cjay175 » January 24th, 2011, 2:00 am

After thinking about for a bit I realized I was going about it totally wrong, it was actually quite easy to implement this with this plugin.

Just incase someone else is wondering, I first put this in the top of config-user-registration-inc.php of s2member (i guess you could put it in wp-signup too or something i dunno). THis is used to block the registration page and force to choose which user they want to sign up as.

Code: Select all
$user_type = $_GET['user_type'];
$query = $_GET['action'];
if ((!ereg ("TypeB|TypeA", $user_type))&&($query == "register")){
echo <<<END
<div style="height:800px; width:100%; z-index:50; background-color:#FFF; position:absolute; text-align:center;">
<form method="GET" action="/wp-login.php">
<label>Choose Your User Type: </label>
<input name="action" type="hidden" value="register" />
<select name="user_type" id="user_type">
<option selected="selected" value="Please Choose">Please Select</option>
<option value="TypeA">TypeA</option>
<option value="TypeB">TypeB</option>
</select>
<input type="submit" value="Submit" />
</form>
</div>
END;
} else if (($user_type == "TypeB")||($user_type == "TypeA")) {
//The original code from said page goes here
}

This will just make sure the query is at the end of the uri - (ie. /wp-login?action=register&user_type=typeA)

Then I added my input based on a if clause of php to custom-reg-fields-inc.php, again im sure you could add them to wp-signup or something.

So for example something like this with a link to change user type ass well:

Code: Select all
$user_type = $_GET['user_type'];
            echo "<p><input id='user_type_input' type='text' readonly='readonly' name='user_type_input' value='$user_type' />
         <label for='user_type'>User Type</label><br><small>Note* This cannot be changed after registeration</small><br/>To change this user type <a href='/wp-login.php?action=register'>Click Here</a></p>";
         if ($user_type == "typeA"){
echo <<<END
<label>User Type A Name</label><input  name="userA_name" type="text" />
END;
} else if ($user_type == "typeB") {
echo <<<END
<label>User Type B Name</label><input  name="userB_name" type="text" />
END;
}


Now the form will be displayed depending on what user type is selected

To post the variables and update a user_meta with them you just add this to registration.php around line 202

Code: Select all
                           
$user_type = $_POST["user_type_input"]; //from hidden field above
if ($user_type == "typea"){
update_user_meta ($user_id, "user_type_name", $_POST['userA_name']);
} else if ($user_type == "typeb"){
update_user_meta ($user_id, "user_type", $_POST['userB_name']);
}


- I know this isn't that clean but I am just posting as more of a direction to go with. Also this will still display the basic input fields for wordpress which are first name, last name, email, and user.

thanks for the great plugin
User avatar
cjay175
Registered User
Registered User
 
Posts: 2
Joined: January 23, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 2 guests

cron