BryanB Posted February 12, 2010 Share Posted February 12, 2010 Can anyone help me with a way to activate the affiliate account automatically when an account is created? I've created a new registration form for affiliates only and would like to add something to it that will set the affiliate account as active once the register... I've basically duplicated the registration page, added some extra fields for affiliates only but now don't know what to add to activate the affiliate account. <p>Please fill in the fields below to apply for our partner program. Fields marked with a * are required.<br /> <br /> Already have a client account? Click <a href="https://virtualstagingsolutions.com/dashboard/clientarea.php">here</a> to <a href="https://virtualstagingsolutions.com/dashboard/clientarea.php">log in</a>. Then choose the <a href="https://virtualstagingsolutions.com/dashboard/affiliates.php">affiliate link</a> at the top to activate your affiliate account. </p> <form method="post" action="/dashboard/register.php"> <input type="hidden" name="register" value="true" /> <table width="100%" cellspacing="0" cellpadding="0" class="frame"> <tr> <td><table width="100%" border="0" cellpadding="10" cellspacing="0"> <tr> <td width="150" class="fieldarea">First Name</td> <td><input type="text" name="firstname" size="30" value="" /> *</td> </tr> <tr> <td class="fieldarea">Last Name</td> <td><input type="text" name="lastname" size="30" value="" /> *</td> </tr> <tr> <td class="fieldarea">Company Name</td> <td><input type="text" name="companyname" size="30" value="" /></td> </tr> <tr> <td class="fieldarea">Email Address</td> <td><input type="text" name="email" size="50" value="" /> *</td> </tr> <tr> <td class="fieldarea">Address 1</td> <td><input type="text" name="address1" size="40" value="" /> *</td> </tr> <tr> <td class="fieldarea">Address 2</td> <td><input type="text" name="address2" size="30" value="" /></td> </tr> <tr> <td class="fieldarea">City</td> <td><input type="text" name="city" size="30" value="" /> *</td> </tr> <tr> <td class="fieldarea">State/Region</td> <td><input type="text" name="state" size="25" value="" /> *</td> </tr> <tr> <td class="fieldarea">Zip Code</td> <td><input type="text" name="postcode" size="10" value="" /> *</td> </tr> <tr> <td class="fieldarea">Country</td> <td><select name="country"><option value="AF">Afghanistan</option><option value="AX">Aland Islands</option><option value="AL">Albania</option><option value="DZ">Algeria</option><option value="AS">American Samoa</option><option value="AD">Andorra</option><option value="AO">Angola</option><option value="AI">Anguilla</option><option value="AQ">Antarctica</option><option value="AG">Antigua And Barbuda</option><option value="AR">Argentina</option><option value="AM">Armenia</option><option value="AW">Aruba</option><option value="AU">Australia</option><option value="AT">Austria</option><option value="AZ">Azerbaijan</option><option value="BS">Bahamas</option><option value="BH">Bahrain</option><option value="BD">Bangladesh</option><option value="BB">Barbados</option><option value="BY">Belarus</option><option value="BE">Belgium</option><option value="BZ">Belize</option><option value="BJ">Benin</option><option value="BM">Bermuda</option><option value="BT">Bhutan</option><option value="BO">Bolivia</option><option value="BA">Bosnia And Herzegovina</option><option value="BW">Botswana</option><option value="BV">Bouvet Island</option><option value="BR">Brazil</option><option value="IO">British Indian Ocean Territory</option><option value="BN">Brunei Darussalam</option><option value="BG">Bulgaria</option><option value="BF">Burkina Faso</option><option value="BI">Burundi</option><option value="KH">Cambodia</option><option value="CM">Cameroon</option><option value="CA">Canada</option><option value="CV">Cape Verde</option><option value="KY">Cayman Islands</option><option value="CF">Central African Republic</option><option value="TD">Chad</option><option value="CL">Chile</option><option value="CN">China</option><option value="CX">Christmas Island</option><option value="CC">Cocos (Keeling) Islands</option><option value="CO">Colombia</option><option value="KM">Comoros</option><option value="CG">Congo</option><option value="CD">Congo, Democratic Republic</option><option value="CK">Cook Islands</option><option value="CR">Costa Rica</option><option value="CI">Cote D'Ivoire</option><option value="HR">Croatia</option><option value="CU">Cuba</option><option value="CY">Cyprus</option><option value="CZ">Czech Republic</option><option value="DK">Denmark</option><option value="DJ">Djibouti</option><option value="DM">Dominica</option><option value="DO">Dominican Republic</option><option value="EC">Ecuador</option><option value="EG">Egypt</option><option value="SV">El Salvador</option><option value="GQ">Equatorial Guinea</option><option value="ER">Eritrea</option><option value="EE">Estonia</option><option value="ET">Ethiopia</option><option value="FK">Falkland Islands (Malvinas)</option><option value="FO">Faroe Islands</option><option value="FJ">Fiji</option><option value="FI">Finland</option><option value="FR">France</option><option value="GF">French Guiana</option><option value="PF">French Polynesia</option><option value="TF">French Southern Territories</option><option value="GA">Gabon</option><option value="GM">Gambia</option><option value="GE">Georgia</option><option value="DE">Germany</option><option value="GH">Ghana</option><option value="GI">Gibraltar</option><option value="GR">Greece</option><option value="GL">Greenland</option><option value="GD">Grenada</option><option value="GP">Guadeloupe</option><option value="GU">Guam</option><option value="GT">Guatemala</option><option value="GG">Guernsey</option><option value="GN">Guinea</option><option value="GW">Guinea-Bissau</option><option value="GY">Guyana</option><option value="HT">Haiti</option><option value="HM">Heard Island & Mcdonald Islands</option><option value="VA">Holy See (Vatican City State)</option><option value="HN">Honduras</option><option value="HK">Hong Kong</option><option value="HU">Hungary</option><option value="IS">Iceland</option><option value="IN">India</option><option value="ID">Indonesia</option><option value="IR">Iran, Islamic Republic Of</option><option value="IQ">Iraq</option><option value="IE">Ireland</option><option value="IM">Isle Of Man</option><option value="IL">Israel</option><option value="IT">Italy</option><option value="JM">Jamaica</option><option value="JP">Japan</option><option value="JE">Jersey</option><option value="JO">Jordan</option><option value="KZ">Kazakhstan</option><option value="KE">Kenya</option><option value="KI">Kiribati</option><option value="KR">Korea</option><option value="KW">Kuwait</option><option value="KG">Kyrgyzstan</option><option value="LA">Lao People's Democratic Republic</option><option value="LV">Latvia</option><option value="LB">Lebanon</option><option value="LS">Lesotho</option><option value="LR">Liberia</option><option value="LY">Libyan Arab Jamahiriya</option><option value="LI">Liechtenstein</option><option value="LT">Lithuania</option><option value="LU">Luxembourg</option><option value="MO">Macao</option><option value="MK">Macedonia</option><option value="MG">Madagascar</option><option value="MW">Malawi</option><option value="MY">Malaysia</option><option value="MV">Maldives</option><option value="ML">Mali</option><option value="MT">Malta</option><option value="MH">Marshall Islands</option><option value="MQ">Martinique</option><option value="MR">Mauritania</option><option value="MU">Mauritius</option><option value="YT">Mayotte</option><option value="MX">Mexico</option><option value="FM">Micronesia, Federated States Of</option><option value="MD">Moldova</option><option value="MC">Monaco</option><option value="MN">Mongolia</option><option value="ME">Montenegro</option><option value="MS">Montserrat</option><option value="MA">Morocco</option><option value="MZ">Mozambique</option><option value="MM">Myanmar</option><option value="NA">Namibia</option><option value="NR">Nauru</option><option value="NP">Nepal</option><option value="NL">Netherlands</option><option value="AN">Netherlands Antilles</option><option value="NC">New Caledonia</option><option value="NZ">New Zealand</option><option value="NI">Nicaragua</option><option value="NE">Niger</option><option value="NG">Nigeria</option><option value="NU">Niue</option><option value="NF">Norfolk Island</option><option value="MP">Northern Mariana Islands</option><option value="NO">Norway</option><option value="OM">Oman</option><option value="PK">Pakistan</option><option value="PW">Palau</option><option value="PS">Palestinian Territory, Occupied</option><option value="PA">Panama</option><option value="PG">Papua New Guinea</option><option value="PY">Paraguay</option><option value="PE">Peru</option><option value="PH">Philippines</option><option value="PN">Pitcairn</option><option value="PL">Poland</option><option value="PT">Portugal</option><option value="PR">Puerto Rico</option><option value="QA">Qatar</option><option value="RE">Reunion</option><option value="RO">Romania</option><option value="RU">Russian Federation</option><option value="RW">Rwanda</option><option value="BL">Saint Barthelemy</option><option value="SH">Saint Helena</option><option value="KN">Saint Kitts And Nevis</option><option value="LC">Saint Lucia</option><option value="MF">Saint Martin</option><option value="PM">Saint Pierre And Miquelon</option><option value="VC">Saint Vincent And Grenadines</option><option value="WS">Samoa</option><option value="SM">San Marino</option><option value="ST">Sao Tome And Principe</option><option value="SA">Saudi Arabia</option><option value="SN">Senegal</option><option value="RS">Serbia</option><option value="SC">Seychelles</option><option value="SL">Sierra Leone</option><option value="SG">Singapore</option><option value="SK">Slovakia</option><option value="SI">Slovenia</option><option value="SB">Solomon Islands</option><option value="SO">Somalia</option><option value="ZA">South Africa</option><option value="GS">South Georgia And Sandwich Isl.</option><option value="ES">Spain</option><option value="LK">Sri Lanka</option><option value="SD">Sudan</option><option value="SR">Suriname</option><option value="SJ">Svalbard And Jan Mayen</option><option value="SZ">Swaziland</option><option value="SE">Sweden</option><option value="CH">Switzerland</option><option value="SY">Syrian Arab Republic</option><option value="TW">Taiwan</option><option value="TJ">Tajikistan</option><option value="TZ">Tanzania</option><option value="TH">Thailand</option><option value="TL">Timor-Leste</option><option value="TG">Togo</option><option value="TK">Tokelau</option><option value="TO">Tonga</option><option value="TT">Trinidad And Tobago</option><option value="TN">Tunisia</option><option value="TR">Turkey</option><option value="TM">Turkmenistan</option><option value="TC">Turks And Caicos Islands</option><option value="TV">Tuvalu</option><option value="UG">Uganda</option><option value="UA">Ukraine</option><option value="AE">United Arab Emirates</option><option value="GB">United Kingdom</option><option value="US" selected="selected">United States</option><option value="UM">United States Outlying Islands</option><option value="UY">Uruguay</option><option value="UZ">Uzbekistan</option><option value="VU">Vanuatu</option><option value="VE">Venezuela</option><option value="VN">Viet Nam</option><option value="VG">Virgin Islands, British</option><option value="VI">Virgin Islands, U.S.</option><option value="WF">Wallis And Futuna</option><option value="EH">Western Sahara</option><option value="YE">Yemen</option><option value="ZM">Zambia</option><option value="ZW">Zimbabwe</option></select> *</td> </tr> <tr> <td class="fieldarea">Phone Number</td> <td><input type="text" name="phonenumber" size="20" value="" /> *</td> </tr> </table></td> </tr> </table> <br /> <table width="100%" cellspacing="0" cellpadding="0" class="frame"> <tr> <td><table width="100%" border="0" cellpadding="10" cellspacing="0"> <tr> <td class="fieldarea">Please choose a security question</td> <td><select name="securityqid"> <option value="12">Where were you born?</option> <option value="5">What was your childhood nickname? </option> <option value="6">In what city or town was your first job?</option> <option value="7">What are the last 5 digits of your driver's license number?</option> <option value="8">What is your first dog's name?</option> <option value="9">What is your mother's maiden name?</option> <option value="10">Who is your favorite musician?</option> <option value="11">What are the last 4 digits of your credit card number?</option> </select> *</td> </tr> <tr> <td class="fieldarea">Please enter an answer</td> <td><input type="password" name="securityqans" size="30" /> *</td> </tr> <tr> <td class="fieldarea">Your Website</td> <td><input type="text" size="30" name="customfield[1]" value=""> </td> </tr> <tr> <td class="fieldarea">How did you hear about us?</td> <td><select name="customfield[7]"><option value="-">-</option><option value="Google">Google</option><option value=" Realtor Magazine"> Realtor Magazine</option><option value=" Friend/Colleague"> Friend/Colleague</option><option value=" Newspaper"> Newspaper</option><option value=" Magazine"> Magazine</option><option value=" Email"> Email</option><option value=" Affiliate"> Affiliate</option><option value=" Radio"> Radio</option><option value=" TV"> TV</option><option value=" Trade Show"> Trade Show</option><option value=" Other"> Other</option></select> * </td> </tr> <tr> <td class="fieldarea">Mobile Phone Number</td> <td><input type="text" size="30" name="customfield[13]" value=""> </td> </tr> <tr> <td class="fieldarea">What is your primary marketing plan?</td> <td><select name="customfield[14]"><option value="" selected></option><option value="Pay Per Click">Pay Per Click</option><option value=" My own website"> My own website</option><option value=" Search Engine Optimization"> Search Engine Optimization</option><option value=" Locally"> Locally</option><option value=" TV"> TV</option><option value=" Radio"> Radio</option><option value=" Print"> Print</option><option value=" E-Mail"> E-Mail</option><option value=" Other"> Other</option></select> * </td> </tr> <tr> <td valign="top" class="fieldarea"><p>Describe your marketing plan</p></td> <td><textarea name="customfield[15]" cols="60" rows="6"></textarea> * </td> </tr> <tr> <td class="fieldarea">Social Security Number</td> <td><input type="text" size="30" name="customfield[16]" value=""> <br /> You may leave this blank but you will need to provide it before we can send your first payment</td> </tr> <tr> </table></td> </tr> </table> </form> 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted February 12, 2010 Share Posted February 12, 2010 You can do this with an action hook when the client registers: <?php add_hook("ClientAdd",0,"affiliate_ClientAdd",""); function affiliate_ClientAdd($vars) { $result = full_query ("INSERT INTO tblaffiliates (clientid, date) VALUES ('".$vars['userid']."', now())"); logactivity("Activated Affiliate Account (User ID: ".$vars['userid'].")"); } ?> Give the file an creative name (like affiliate.php ) and put it in the /includes/hooks folder. 0 Quote Link to comment Share on other sites More sharing options...
BryanB Posted February 12, 2010 Author Share Posted February 12, 2010 You can do this with an action hook when the client registers: <?php add_hook("ClientAdd",0,"affiliate_ClientAdd",""); function affiliate_ClientAdd($vars) { $result = full_query ("INSERT INTO tblaffiliates (clientid, date) VALUES ('".$vars['userid']."', now())"); logactivity("Activated Affiliate Account (User ID: ".$vars['userid'].")"); } ?> Give the file an creative name (like affiliate.php ) and put it in the /includes/hooks folder. Thanks... but will this activate it for all customers or only for the ones that sign up on the new form I made? 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted February 12, 2010 Share Posted February 12, 2010 (edited) Thanks... but will this activate it for all customers or only for the ones that sign up on the new form I made? Only the new ones who sign up using the WHMCS registration function. (so as well via you "custom" page as the registration.php page from WHMCS) Edited February 12, 2010 by m00 0 Quote Link to comment Share on other sites More sharing options...
BryanB Posted February 12, 2010 Author Share Posted February 12, 2010 Only the new ones. sorry, when you say only the new ones, that means all new customers? What I'm trying to do is get only customers that sign up from affiliateregistration.php (the extra registration form that I created) to be activated as an affiliate... I don't want everyone that registers while placing a new order or using the default registration form to be activated. Thanks again. 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted February 12, 2010 Share Posted February 12, 2010 sorry, when you say only the new ones, that means all new customers? What I'm trying to do is get only customers that sign up from affiliateregistration.php (the extra registration form that I created) to be activated as an affiliate... I don't want everyone that registers while placing a new order or using the default registration form to be activated. Thanks again. Change this: <form method="post" action="/dashboard/register.php"> to: <form method="post" action="/dashboard/register.php?affiliate=yes"> And try this as your custom hook: <?php add_hook("ClientAdd",0,"affiliate_ClientAdd",""); function affiliate_ClientAdd($vars) { if($_GET['affiliate'] == "yes") { $result = full_query ("INSERT INTO tblaffiliates (clientid, date) VALUES ('".$vars['userid']."', now())"); logactivity("Activated Affiliate Account (User ID: ".$vars['userid'].")"); } } ?> This will only make users who sign up using your custom registration form an affiliate. 0 Quote Link to comment Share on other sites More sharing options...
BryanB Posted February 12, 2010 Author Share Posted February 12, 2010 thanks, I created all that but it still doesn't activate the affiliate, also... if a field is not filled out that is required it gives the error message but it brings you back to the original registration.php form instead of the new one. Maybe it is easier to send them to /affiliate.php after they register on this form only and they can click the activate button? I'm just not sure how to define what page they go to after the form is submitted and how to send them back to the same form if an error is given? I think this would be a good feature that should be included with WHMCS, I really need it to collect information from affiliates that I do not collect from customers and allow affiliates to sign up and be taken to the affiliate section instead of having to tell them to click "affiliates" in their account and activate it. 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted February 13, 2010 Share Posted February 13, 2010 Maybe it is easier to send them to /affiliate.php after they register on this form only and they can click the activate button? I'm just not sure how to define what page they go to after the form is submitted... You can customize that with the "ClientAdd" action hook. ...and how to send them back to the same form if an error is given I'm affraid that isn't possible. Well, it is possible to redirect the user back to your custom affiliate form when an error occurs, but then the user needs to start fill in all information again. Another solution is to recreate the whole registration process where you can customize all your desired fields for the affiliates only. We have done this for a customer once with the similar goal, but believe me, it isn't easy. 0 Quote Link to comment Share on other sites More sharing options...
BryanB Posted February 13, 2010 Author Share Posted February 13, 2010 hm ok, so if register.php wasn't encrypted do you think I would be able to define where they go when they get an error? 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted February 13, 2010 Share Posted February 13, 2010 hm ok, so if register.php wasn't encrypted do you think I would be able to define where they go when they get an error? Well, when the user gets an error, it just stays on the register.php with the error messages. What we did, is just recreate all the functions from the registration form with build-in error reporting. In this case the user could register for a "normal" client account on the default register.php, or for an affiliate account on the affiliateregister.php page for an affiliate account which also has some added fields. When the user on the affiliteregister.php gets an error, it just stayed on the affiliateregister.php page and returns the errors to the user. 0 Quote Link to comment Share on other sites More sharing options...
aldo Posted February 13, 2010 Share Posted February 13, 2010 hello bryan i am writting a form for affiliates registration. This works for me: //PROCESAR FORMULARIO if(isset($_POST['register'])){$register = sanitize($_POST['register']);} if($register == true){ $form_errors = array(); if(isset($_POST['firstname'])){ $postfields["firstname"] = sanitize($_POST['firstname']); $smartyvalues["clientfirstname"] = $postfields["firstname"]; if(strlen($postfields["firstname"]) < 1){ $form_errors[] = "El nombre ingresado no es válido."; } } if(isset($_POST['lastname'])){ $postfields["lastname"] = sanitize($_POST['lastname']); $smartyvalues["clientlastname"] = $postfields["lastname"]; if(strlen($postfields["lastname"]) < 1){ $form_errors[] = "El apellido ingresado no es válido."; } } $postfields["companyname"] = 'XXXXXX'; if(isset($_POST['email'])){ $postfields["email"] = sanitize($_POST['email']); $smartyvalues["clientemail"] = $postfields["email"]; if(strlen($postfields["email"]) < 1){ $form_errors[] = "El email ingresado no es válido."; } } if(isset($_POST['address1'])){ $postfields["address1"] = sanitize($_POST['address1']); $smartyvalues["clientaddress1"] = $postfields["address1"]; if(strlen($postfields["address1"]) < 3){ $form_errors[] = "La dirección ingresada no es válida."; } } if(isset($_POST['city'])){ $postfields["city"] = sanitize($_POST['city']); $smartyvalues["clientcity"] = $postfields["city"]; } if(isset($_POST['state'])){ $postfields["state"] = sanitize($_POST['state']); $smartyvalues["clientstate"] = $postfields["state"]; } if(isset($_POST['postcode'])){ $postfields["postcode"] = sanitize($_POST['postcode']); $smartyvalues["clientpostcode"] = $postfields["postcode"]; } if(isset($_POST['country'])){ $postfields["country"] = sanitize($_POST['country']); $smartyvalues["clientcountry"] = $postfields["country"]; } $postfields["phonenumber"] = '00000000'; if(isset($_POST['password'])){ $postfields["password"] = sanitize($_POST['password']); $smartyvalues["clientpassword"] = $postfields["password"]; if(strlen($postfields["password"]) < 4){ $form_errors[] = "La contraseña ingresada no es válida. Mínimo 4 caracteres."; } } if(isset($_POST['password2'])){ $postfields["password2"] = sanitize($_POST['password2']); $smartyvalues["clientpassword2"] = $postfields["password2"]; if($postfields["password2"] != $postfields["password"]){ $form_errors[] = "Las contraseñas no coinciden."; } } if(isset($_POST['code'])){ $postfields['code'] = sanitize($_POST['code']); if($_SESSION['image_random_value'] != md5(strtoupper($postfields['code']))){ $form_errors[] = "El código anti SPAM no es válido."; } } if(count($form_errors) > 0){ $error_list = '<ul>'; foreach($form_errors as $error){ $error_list .= '<li>'.$error.'</li>'; } $error_list .= '</ul>'; $smartyvalues["errormessage"] = $error_list; } else{ $url = "http://XXXXXXXX.com/includes/api.php"; # URL to WHMCS API file $username = "XXXX"; # Admin username goes here $password = "XXXX"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "addclient"; $postfields["currency"] = "1"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $results[$temp[0]] = $temp[1]; } if ($results["result"]=="success") { $result = full_query ("INSERT INTO tblaffiliates (clientid, date) VALUES ('".$results['clientid']."', now())"); logactivity("Activated Affiliate Account (User ID: ".$results['clientid'].")"); } else { $error_list = '<ul>'; $error_list .= '<li>'.$results["message"].'</li>'; $error_list .= '</ul>'; $smartyvalues["errormessage"] = $error_list; } } } 0 Quote Link to comment Share on other sites More sharing options...
mysmallbizu Posted November 6, 2010 Share Posted November 6, 2010 Do you have the page where you implemented this? 0 Quote Link to comment Share on other sites More sharing options...
jdwalte3 Posted November 23, 2010 Share Posted November 23, 2010 I am interested in this as well. Anyone implemented a customer affiliate registration page that automatically activates the affiliate? I'd like to see your page and code if possible. JW 0 Quote Link to comment Share on other sites More sharing options...
phort6n2 Posted December 5, 2010 Share Posted December 5, 2010 You can customize that with the "ClientAdd" action hook. How do you direct the user to affiliates.php in the hook? 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted December 5, 2010 Share Posted December 5, 2010 Add this at the bottom of the action hook function: header("Location: affiliates.php"); 0 Quote Link to comment Share on other sites More sharing options...
phort6n2 Posted December 10, 2010 Share Posted December 10, 2010 Does this go at the bottom of the hook that you created above? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.