Jump to content

Custom module


derekb

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • WHMCS CEO

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated