derekb Posted September 9, 2008 Share Posted September 9, 2008 Hi, we are trialling the WHMCS demo and it all looks excellent. I've managed to created a custom module to provision users on our servers which are not handled by any of the built-in modules. One issue and stumbling block is the generation of the username & password associated with the clients "product". The WHMCS generates a random password automatically under the "Products/Services" and is shown in the password text box but the "username" text box is left blank. Is this by design ? It means I can't automate account creation as after an order is placed I manually have to go into the client product and type in a username, save it and then use the "create" button to provision the user on the host server. Am I missing something obvious here ? Where should I look to generate a username & password automatically ? And since I'm on here I notice that if I setup a product as FREE the order form still asks the client to choose a payment type. Is this a know issue ? Thanks, Derek 0 Quote Link to comment Share on other sites More sharing options...
chickendippers Posted September 9, 2008 Share Posted September 9, 2008 We use the cPanel module and the username field is most definitely filled in. Must be a bug in your custom coding. 0 Quote Link to comment Share on other sites More sharing options...
derekb Posted September 9, 2008 Author Share Posted September 9, 2008 Hi, there is no custom code to fill in the username or password. the WHMCS system genertes the random password for the server user but not the username. That is left blank I am just taking the variables that are populated on the product page, username,password, some custom options and then passing them to our server api to create a user. I am not programatically generateing a username or password. I would like tge WHMCS system to generate the server/package username & password that would then be passed to our hosting servers API. The username & password needs to be generated automatically in order to allow automatic provisioning when a client puts a paid order through the system. Thanks, Derek. 0 Quote Link to comment Share on other sites More sharing options...
derekb Posted September 10, 2008 Author Share Posted September 10, 2008 I setup a test product and assigned the cPanel module to it. I ran through a dummy order and when you go into the Manage Orders page the username is blank but the password generated by WHHCS is there. I assume there should be a random username generated or pulled in from elsewhere in the system ? If not how do I automate the generation of the username for the server Thanks, Derek 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted September 10, 2008 WHMCS CEO Share Posted September 10, 2008 Usernames are generated from the domain the user provides. If you are creating a module for a product where you don't collect a domain from the user, you need to generate your own username. Matt 0 Quote Link to comment Share on other sites More sharing options...
derekb Posted September 10, 2008 Author Share Posted September 10, 2008 hi matt, thanks for that , not so obvious ,answer We don't require a domain name from the client as it's not used in account provisioning. So at what point do I create the username. Do I do it the custom module and insert a username into the database directly with an sql command ? Will the "create account" event fire automatically after the custom module runs ? At the moment I have the code running under the "function mymodule_CreateAccount($params} section of the customer module code template. Will the username not need to be created before that function/event runs ? I'm assuming the sequence of events to automate signup is; 1. client signs up 2. client choose package & pays for it. 3. WHMCS system adds package to client account 4. WHMCS system attempts to run the mymodule_CreateAccount($params} function in the customer module to provision remote server account I need a pointer as to where and what stage to create the username for the remote server. thanks for the help. derek 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted September 10, 2008 WHMCS CEO Share Posted September 10, 2008 Yes, just create the username inside your modules create function and then save it to the DB record. Here's an example using the clients first and last names. $username = strtolower($params["clientsdetails"]["firstname"].$params["clientsdetails"]["lastname"]); $username = preg_replace('/[^a-z]/', '', $username); mysql_query("UPDATE tblhosting SET username='$username' WHERE id='".$params["serviceid"]."'"); Matt 0 Quote Link to comment Share on other sites More sharing options...
derekb Posted September 10, 2008 Author Share Posted September 10, 2008 exactly what I was looking for. I'll give it a go. Thanks, Derek 0 Quote Link to comment Share on other sites More sharing options...
derekb Posted September 10, 2008 Author Share Posted September 10, 2008 UPDATE: you code snippet works perfectly using custom generated username. Just one other point which was mentioned in the first post. If we setup a FREE product on the order form should the payment type be showing up. e.g If we have a free trial and the client orders it , the order form asks for a payment type event though a payment isn't required. Thanks once again. 0 Quote Link to comment Share on other sites More sharing options...
djbanks Posted September 15, 2008 Share Posted September 15, 2008 We had this same issue, we got round it by using an if in the template. inside viewcart.tpl we put {if $total ne '£0.00 GBP'} {/if} around the select payment type table elements. you would obviously need to change the £0.00 GBP to whatever currency you are using. 0 Quote Link to comment Share on other sites More sharing options...
derekb Posted September 15, 2008 Author Share Posted September 15, 2008 thanks djbanks, I had worked out that I might need to do something like that after checking out every conceiveable option in the system, although I wasn't sure which template. Thats for that, will save be time searching. Strange that it isn't built into the system, considering that there is an option for a FREE product. Derek. 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.