Jump to content

Automatic Subdomain Creation on Account Creation


Recommended Posts

I wanted to take advantage of the cPanel proxy so users could access cPanel, webmail, webdisk and WHM from behind a firewall at school or work. What I found was cPanel Proxy.

 

Attached are all of the files you need to make this happen. I will not provide any support for this, I am only sharing my experience.

 

STEP 1: you need to login to upload the contents of skel.zip to your /root/cpanel-skel/public_html/ directory as root on your hosting server.

 

This should give you four new folders: whm, cpanel, webdisk and webmail.

 

STEP 2: copy class.cpanel.php.txt to your whmcs/includes/ folder as class.cpanel.php.

 

STEP 3: modify your actionhooks.php file and find the actionhook_AfterModuleCreate function and make it look like this:

function actionhook_AfterModuleCreate($vars) {
# This function runs when a module creation command completes successfully - various variables available

if (($vars['moduletype'] == 'cpanel') && ($vars['producttype'] == 'hostingaccount'))
{
  include("class.cpanel.php");

	$cuser = $vars['username'];
	$cpass = $vars['password'];
	$cdomain = $vars['domain'];

	if ($cpanel = new cpanel($cuser,$cpass,$cdomain))
	{
		$cpanel->CreateSubDomain("cpanel",$cdomain);
		$cpanel->CreateSubDomain("webmail",$cdomain);
		$cpanel->CreateSubDomain("webdisk",$cdomain);
		$cpanel->CreateSubDomain("whm",$cdomain);
	}
}
}

 

Now whenever a new customer registers, when the system creates their cpanel account, the subdomains will be automatically created.

 

If you find a way to improve on this, please feel free to share.

 

Note:

If you aren't using the x3 theme as your default theme, you will need to modify line 9 of class.cpanel.php with your default them.

skel.zip

class.cpanel.php.txt

Link to comment
Share on other sites

  • 2 months later...
Hi, do you now how it can create SUB DOMAINS on the server - is there anything out there?

 

Look in the source for class.cpanel.php

 

function CreateSubDomain($subdomain,$domain) {
	@file("http://".$this->set_username.":".$this->set_password."@".$this->set_domain.":".$this->set_port."/frontend/".$this->set_theme.
		"/subdomain/doadddomain.html?domain=".$subdomain."&rootdomain=".$domain);
}

function DeleteSubDomain($subdomain,$domain) {
	@file("http://".$this->set_username.":".$this->set_password."@".$this->set_domain.":".$this->set_port."/frontend/".$this->set_theme.
		"/subdomain/dodeldomain.html?domain=".$subdomain."_".$domain);
}

Link to comment
Share on other sites

  • 3 weeks later...

That would require a lot of core cpanel module updates. Such as after account login to pay, an action to ask should this be a new hosting account or an addon-domain to existing cpanel account user, check if that feature is available for that package and if max addon-domains has already been reached in which an addon to sale additional addon-domain package upgrade.

Link to comment
Share on other sites

It depends how IT literate your customer is. A lot of ours are small business types with low literacy, they just want to pay us to do the whole thing. I'd kind of like the ability to do this from WHMCS too, esp if I could arrange for it to just 302-redirect to the main domain - would be heaven :)

Link to comment
Share on other sites

  • 5 months later...

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