DavidBee Posted July 31, 2012 Share Posted July 31, 2012 Hello WHMCS Forums! I currently have a working order form using the API but I am trying to cut down the amount of required fields so would like to hide the password field and randomly generate passwords for the client area login. Can anyone point me in the correct direction please? Thanks 0 Quote Link to comment Share on other sites More sharing options...
ditto Posted August 1, 2012 Share Posted August 1, 2012 I would also like this. I think it would be even better if WHMCS could completely remove the password fields from the order form as default. It would be much better to have the password get autogenerated by WHMCS and then sent to client after ordering. I think thats generally more secure, because clients often do not make strong enough passwords, also it is like you say a extra field, and I think it would be better to cut down on this for sales ... 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted August 1, 2012 Share Posted August 1, 2012 What you can do is generated a random password using php and then input the password into hidden fields and remove the normal password fields from the viewcart.tpl. At the top of the template add or you can use something similar to generate a random password: {php} $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $size = strlen( $chars ); $generated_password = ""; for( $i = 0; $i < 12; $i++ ) { $generated_password .= $chars[ rand( 0, $size - 1 ) ]; } $this->assign('generated_password',$generated_password); {/php} You can add the following hidden fields near the submit button. {if !$loggedin} <input type="hidden" name="password" value="{$generated_password}" /> <input type="hidden" name="password2" value="{$generated_password}" /> {/if} Then remove these two fields from the form and the password strength field as well and a random client area password will be generated. 0 Quote Link to comment Share on other sites More sharing options...
DavidBee Posted August 1, 2012 Author Share Posted August 1, 2012 I have created a custom API form where I am not using the viewcart.tpl. After info is filled out its direct to invoice. I did try to generate a random password with no success. Kept asking me to enter pass. 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted August 1, 2012 Share Posted August 1, 2012 The API does allow you to create clients and pass it a password for the new client, make you are passing the parameter as password2 and not password. If that isn't your issue, if you post your code here, someone may be able to see what is wrong with it. 0 Quote Link to comment Share on other sites More sharing options...
DavidBee Posted August 2, 2012 Author Share Posted August 2, 2012 We here is the what I am trying to use to generate a random password. function generate_password($len = { $chars = str_split('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#'); for($i=0; $i < $len; $i++) $password .= $chars[rand(1, $sizeof($chars)) -1]; return $password; } 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted August 2, 2012 Share Posted August 2, 2012 Can you please post the calls you are making to the API not how you are generating the passwords. 0 Quote Link to comment Share on other sites More sharing options...
DavidBee Posted August 2, 2012 Author Share Posted August 2, 2012 Sorry was meaning to post that up also. I am not at the computer with the code on at the moment but its based on Matts post: forum.whmcs.com/showthread.php?12169-Remote-Order-Form-using-the-API 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.