These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for WHMCS - Virtualmin Username Standardization on the new forum.
The way I was able to get around the default WHMCS username generated (first 8 chars of domain) and create usernames consistent with my settings in Virtualmin :
Created a file named virtualmin-domain-usernames.php inside of includes/hooks/
Pasted the following content into that file :
<div class="codeblock"><pre><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">&</span><span style="color: #FF8000">#10;function apply_custom_username_fulldomain($vars) { $orderID = $vars['OrderID']; $result = mysql_query("SELECT * FROM tblhosting WHERE orderid=$orderID"); while ($data = mysql_fetch_array($result)) { $id = $data["id"]; // make custom $username var here based on full domain $username = $data["domain"]; $queryresult = mysql_query("UPDATE tblhosting SET username='$username' WHERE id=$id"); } } function apply_custom_username_firstpartofdomain($vars) { $orderID = $vars['OrderID']; $result = mysql_query("SELECT * FROM tblhosting WHERE orderid=$orderID"); while ($data = mysql_fetch_array($result)) { $id = $data["id"]; $domainparts = explode(".",$data["domain"]); // make custom $username var here based on first part of domain $username = $domainparts[0]; $queryresult = mysql_query("UPDATE tblhosting SET username='$username' WHERE id=$id"); } } add_hook("AfterShoppingCartCheckout",1,"apply_custom_username_firstpartofdomain"); // add_hook("AfterShoppingCartCheckout",1,"apply_custom_username_fulldomain"); <br /></span><span style="color: #0000BB">?></span></span></code></pre></div>
If you use the entire domain.TLD as the username, comment out the first add_hook line and uncomment the second.
~Jeremy
Thanks good info, thanks for sharing how you solved that!
-Eric
Did you run into the issue that WHMCS ignores the custom username you set for Virtualmin service setup, and always reverts to its default scheme?
I submitted that as a bug report to the WHMCS people and received a corrected "virtualmin.php" file for use in WHMCS, which fixed the issue for me.
If you're interested, I can send you that file. :)