Jump to content

License Registered to: Admin Side Bar


zitu4life

Recommended Posts

Hello

When we buy a license directly to whmcs.com it will be registered to our personal name or company name, OK

but 

When we bought from hosting provider it will be registered to hosting provider and also will displayed on side bar as Registered To: Hosting Company name

I know I can edit a Sidebar.tpl file and override it to any name I want, but I am looking for a way do not need to edited on every WHMCS update.

a Hook that could replaced hosting registed name to a WHMCS company instalation name for example.

image.png.875fed56b2f8609c7da9a3a1c0e5c83c.png

 

Link to comment
Share on other sites

13 hours ago, zitu4life said:

a Hook that could replaced hosting registed name to a WHMCS company instalation name for example.

the trick with this is to just look in sidebar.tpl and see what the variable is called - and then overwrite it with a hook.

<?php

# Change License Registered Name in Admin Sidebar Hook
# Written by brian!

function license_registered_name_in_admin_sidebar_hook($vars) {
	
	$licenseinfo = $vars['licenseinfo'];
	$licenseinfo['registeredname'] = "Theresa May";
	return array("licenseinfo" => $licenseinfo);	
}
add_hook("AdminAreaPage", 1, "license_registered_name_in_admin_sidebar_hook");

bh2xXtn.png

Link to comment
Share on other sites

Many thanks @brian! It works fine, but would be wonderful if where possible to insert {$company_name}, so this hook will automatically looks at a company name and displayed on registered to: {$company_name}, so it will more automate . I have tested it but if I replace Theresa May to {$company_name} it do not work, it do not display anything.

But anyway I am happy with this hook.

thanks!!

Link to comment
Share on other sites

Have found another place where we found this information license registered to: HOSTING PROVIDER, but there i even do not know in which file tpl they are stored, so I do not known if ti is possible to override it with hook or editing tpl file.

image.thumb.png.5a65ffe4f8bd59bc494dc16f6be38783.png

Edited by zitu4life
Link to comment
Share on other sites

12 hours ago, zitu4life said:

Many thanks @brian! It works fine, but would be wonderful if where possible to insert {$company_name}, so this hook will automatically looks at a company name and displayed on registered to: {$company_name}, so it will more automate . I have tested it but if I replace Theresa May to {$company_name} it do not work, it do not display anything.

it won't - it's not a value that's available in the template.... you'd have to pull it from the database.

usually, i'd use Capsule - but as this is a configuration value, there's another way...

<?php

# Change License Registered Name in Admin Sidebar Hook
# Written by brian!

use WHMCS\Config\Setting;

function license_registered_name_in_admin_sidebar_hook($vars) {
    
    $companyname = Setting::getValue('CompanyName');
    if ($companyname) {
        $licenseinfo = $vars['licenseinfo'];
        $licenseinfo['registeredname'] = $companyname;
        return array("licenseinfo" => $licenseinfo);
    }
}
add_hook("AdminAreaPage", 1, "license_registered_name_in_admin_sidebar_hook");
10 hours ago, zitu4life said:

Have found another place where we found this information license registered to: HOSTING PROVIDER, but there i even do not know in which file tpl they are stored, so I do not known if ti is possible to override it with hook or editing tpl file.

it's not a template, it'll likely be hardcoded in the index.php file... needless to say there are no IDs used in their code, so attacking it JS/JQuery/css is awkward, but doable if you can hardcode the two strings (e.g not pull them from the db).... alternatively you could remove the link to this page from the menu using a hook if you wanted to - actually, you could do that with css, but as the admin templates still don't have their own custom.css file, you would need a hook.

 

 

Link to comment
Share on other sites

5 hours ago, brian! said:

alternatively you could remove the link to this page from the menu using a hook if you wanted to - actually, you could do that with css, but as the admin templates still don't have their own custom.css file, you would need a hook.

Using custom CSS we will have a gap on Sub-menu. 

#Menu-Help-License_Information{display: none;}

image.png.fa97dc130cb7e481779afe494f95569e.png

 

Perhaps we should appeal to MENU tpl file editor, unless there is a way after applying a custom CSS to auto recompile  template. I have seem I Admin Template that could use CSS and then remove those gaps automatically, but no ideas how developer did that.

<li><a id="Menu-Help" title="Help" href=""><span class="hidden-xs">{$_ADMINLANG.help.title}</span><span class="visible-xs"><i class="far fa-life-ring"></i></span></a>
  <ul>
    <li><a id="Menu-Help-Documentation" href="http://docs.whmcs.com/" target="_blank">{$_ADMINLANG.help.docs}</a></li>
    {if in_array("Main Homepage",$admin_perms)}<li><a id="Menu-Help-License_Information" href="{routePath('admin-help-license')}">{$_ADMINLANG.help.licenseinfo}</a></li>{/if}
    {if in_array("Configure Administrators",$admin_perms)}<li><a id="Menu-Help-Change_License_Key" href="licenseerror.php?licenseerror=change">{$_ADMINLANG.help.changelicense}</a></li>{/if}
    {if in_array("Health and Updates", $admin_perms)}
        <li>
            <a id="Menu-Help-Check_Health_Updates" href="systemhealthandupdates.php">
                {$_ADMINLANG.healthCheck.menuTitle}
            </a>
        </li>
    {/if}
    {if in_array("View What's New",$admin_perms)}
        <li>
            <a id="Menu-Help-Whats_New" href="javascript:openFeatureHighlights()">
                {$_ADMINLANG.whatsNew.menuTitle}
            </a>
        </li>
    {/if}
    {if in_array("Configure General Settings",$admin_perms)}
        <li><a id="Menu-Help-Setup_Wizard" href="#" onclick="openSetupWizard();return false;">{$_ADMINLANG.help.setupWizard}</a></li>
        <li><a id="Menu-Help-Get_Help" href="systemsupportrequest.php">{$_ADMINLANG.help.support}</a></li>
    {/if}
    <li><a id="Menu-Help-Community_Forums" href="https://whmcs.community/?utm_source=InApp&utm_medium=Help_Menu" target="_blank">{$_ADMINLANG.help.forums}</a></li>

 

Link to comment
Share on other sites

14 hours ago, zitu4life said:

Using custom CSS we will have a gap on Sub-menu. 

yeah - I only quickly glanced at the menu code, saw that the link had an ID and assumed the rest... sadly, we're still back in the 2010s or whenever with their parent tags not having IDs.

14 hours ago, zitu4life said:

Perhaps we should appeal to MENU tpl file editor, unless there is a way after applying a custom CSS to auto recompile  template.

that code tells me that for any admin user who you don't want to see this license page, you could uncheck remove "Main Homepage" from their administrator roles... that will remove the link from the menu, though would probably prevent them seeing most of the widgets on the homepage too.

15 hours ago, zitu4life said:

I have seem I Admin Template that could use CSS and then remove those gaps automatically, but no ideas how developer did that.

they've probably been designed using modern standards - the menu in Blend, other than slight styling changes, hasn't really changed much in the 4-5 years it's been out... here's what it looked like in v5.3  with the code used...

gQgek3b.png

<li><a id="Menu-Help" title="Help" href="">{$_ADMINLANG.help.title}</a>
  <ul>
    <li><a id="Menu-Help-Documentation" href="http://docs.whmcs.com/" target="_blank">{$_ADMINLANG.help.docs}</a></li>
    {if in_array("Main Homepage",$admin_perms)}<li><a id="Menu-Help-License_Information" href="systemlicense.php">{$_ADMINLANG.help.licenseinfo}</a></li>{/if}
    {if in_array("Configure Administrators",$admin_perms)}<li><a id="Menu-Help-Change_License_Key" href="licenseerror.php?licenseerror=change">{$_ADMINLANG.help.changelicense}</a></li>{/if}
    {if in_array("Configure General Settings",$admin_perms)}<li><a id="Menu-Help-Check_For_Updates" href="systemupdates.php">{$_ADMINLANG.help.updates}</a></li>
    <li><a id="Menu-Help-Get_Help" href="systemsupportrequest.php">{$_ADMINLANG.help.support}</a></li>{/if}
    <li><a id="Menu-Help-Community_Forums" href="http://community.whmcs.com/" target="_blank">{$_ADMINLANG.help.forums}</a></li>
  </ul>

I suppose you could use a redirection hook to prevent selected admin users from seeing the license page - but as you say, you might as well just edit the template...

Link to comment
Share on other sites

i'll post that license info hook that I mentioned previously...

<?php

# Change License Registered Name on License Info Hook
# Written by brian!

function change_license_info_hook($vars) {
	
	if ($vars['pagetitle'] == "License Information") {    
return <<<EOF
<script>
$("tbody").html($("tbody").html().replace('current name','new name'));
</script>
EOF;
};
}
add_hook("AdminAreaFooterOutput",1,"change_license_info_hook");

you will just have to update the values of 'current name' and 'new name' for the existing and replacement registered names.

Link to comment
Share on other sites

49 minutes ago, brian! said:

i'll post that license info hook that I mentioned previously...


<?php

# Change License Registered Name on License Info Hook
# Written by brian!

function change_license_info_hook($vars) {
	
	if ($vars['pagetitle'] == "License Information") {    
return <<<EOF
<script>
$("tbody").html($("tbody").html().replace('current name','new name'));
</script>
EOF;
};
}
add_hook("AdminAreaFooterOutput",1,"change_license_info_hook");

you will just have to update the values of 'current name' and 'new name' for the existing and replacement registered names.

I was thinking in a way that could be possible to say the new hook, on new name to call again WHMCS company name installation $companyname;

With that I will never had to edited this hook again, because, once I edited hook current name with hosting name (that will be always same same), so hook will always replace hosting name to WHMCS company name. It will be a must because even on all WHMCS bought from same hosting, will have displayed name of WHMCS installation company name.

PS: I do not want to change license to another name, but always to WHMCS company name installed.

Link to comment
Share on other sites

25 minutes ago, zitu4life said:

Have tested it and it works for English language, but when Admin changed language to other than English it do not replace that name. If translation string applies here would a must.

ahh - never occurred to me that $pagetitle was translatable... curse of usually not coding on a Saturday!

<?php

# Change License Registered Name on License Info Hook
# Written by brian!

function change_license_info_hook($vars) {
	GLOBAL $_ADMINLANG;
	$licensestring = $_ADMINLANG['license']['title'];
	if ($vars['pagetitle'] == $licensestring) {    
return <<<EOF
<script>
$("tbody").html($("tbody").html().replace('old name','new name'));
</script>
EOF;
};
}
add_hook("AdminAreaFooterOutput",1,"change_license_info_hook");
27 minutes ago, zitu4life said:

No one can stand against you when we are talking regarding WHMCS Hook.

you should have seen what this place was like 5+ years ago - there was far more of a community spirit back then with multiple posters replying to technical threads... I only stand out now because i'm the last one still doing it on a regular basis.

it's not a good situation for any forums to be in to be so reliant on a small number of replying posters... but sadly you can't magic people like me (or the much missed sentq) out of thin air... if they could, i'd happily leave replying to others.

4 minutes ago, zitu4life said:

I was thinking in a way that could be possible to say the new hook, on new name to call again WHMCS company name installation $companyname;

it's a php hook, returning javascript trying to reference php or Smarty variables - i'm not saying it couldn't be done, just not by me quickly today... I tried, but couldn't make it work.

23 minutes ago, zitu4life said:

With that I will never had to edited this hook again, because, once I edited hook current name with hosting name (that will be always same same), so hook will always replace hosting name to WHMCS company name. It will be a must because even on all WHMCS bought from same hosting, will have displayed name of WHMCS installation company name.

PS: I do not want to change license to another name, but always to WHMCS company name installed.

but I assume you're not going to be changing the name every 5 minutes - so yes, it would be nice to be able to pull the info automatically, but I wasn't going to waste a lot of time trying to make it work that way when it's not really that important.

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