Jump to content

Is it possible to have WHMCS use the full domain (instead of first 8 letters) for the username?

Recommended Posts

I'm trying to find a way for WHMCS to use the full domain name (instead of using only the first 8 letters) as the username. The reason being is that I use the username to create my /home/{username} in my control panel.


Currently I have to manually approve each order because I still have to manually input the username.


The closest option I found is: General Settings > Ordering > Enable Random Usernames (Tick this box to generate random usernames for services rather than use the first 8 letters of the domain).


How do I make WHMCS use the full domain name as username automatically?

Link to comment
Share on other sites

Thanks for the pointer on Action Hooks. I was able to find OverrideModuleUsernameGeneration hook, which is probably what I need.


I'm new to writing action hooks, so I'm using the example from includes/hooks/ and have this so far:




function hook_username_domain($vars) {


$username = $vars['domain'];








Can anyone advise if the above is correct?

Link to comment
Share on other sites

your hook need to be something like that


function hook_username_domain($vars) {

   $username = trim(strip_tags($vars['domain']));
   $username = str_replace(array("https://", "http://", "www.", "/"), "", $username);

   return $username;
add_hook("OverrideModuleUsernameGeneration", 1, "hook_username_domain");

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.

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