Jump to content

Hooks for Older WHMCS Version 5.3.14


Recommended Posts

Hello All,

Hope I'm in the right topic category for this. I'm new to the WHMCS world and my employer is asking for some minor updates to the 'client area' of WHMCS. We are currently running version 5.3.14 and all I am trying to accomplish is show the client's current credit balance anywhere in the client area portal. I've already been through the Docs looking at hooks, but every "client area" related hook I've tried, has not worked at all.

For my test, I'm only trying the following:

<?php
add_hook('ClientAreaHome', 1, function($vars) {
    return "Hello World";
});
?>

I'm not sure if the hooks were named something different back in the earlier releases, or if I'm just not finding the right one to accomplish what I am doing. I've also seen conflicting help docs that indicate multiple areas where a 'hooks' related .php file can be placed, so any pointers on that would be appreciated as well. I'm also interested in knowing how to query info from the db inside of WHMCS, as the provided 'Capsule DBAL' seems to also not be working.

Thank you in advance for any tips or pointers in the right direction!

 

P.S. - Yes, we're planning an upgrade to the latest release, but we're a bit up the road from that task still.

Link to comment
Share on other sites

You need to do the following to add a hook:

<?php

function testFunction ($vars) {
	return "Hello World";
}

// Hook point, priority, function name
add_hook("ClientAreaHomepage", 0, "testFunction");

 

10 hours ago, joel_pixelplow said:

I'm also interested in knowing how to query info from the db inside of WHMCS, as the provided 'Capsule DBAL' seems to also not be working.

Capsule is available since WHMCS v6.0. In older releases, you can use the SQL helper functions.

Link to comment
Share on other sites

9 hours ago, joel_pixelplow said:

We are currently running version 5.3.14

ahh my favourite, and first, release - looks crap, but lightweight and works. ☺️

9 hours ago, joel_pixelplow said:

and all I am trying to accomplish is show the client's current credit balance anywhere in the client area portal.

simplest way would be to just edit the relevant .tpl template and add the code below to it where you want to output the balance...

{$clientsstats.creditbalance}
9 hours ago, joel_pixelplow said:

I've already been through the Docs looking at hooks, but every "client area" related hook I've tried, has not worked at all.

the documentation only shows what works for the latest/recent releases - not what would have worked on a version released back in 2013... I suspect for that, you would likely have to take a trip to archive.org, view the whmcs.com site back from 2013, and see what hook options were available back then.

9 hours ago, joel_pixelplow said:

For my test, I'm only trying the following

there isn't a "ClientAreaHome" hook for any version I can remember... maybe you mean ClientAreaHomePage as that would return HTML to the template, but I think that became available with the Six template back in 2015 or whenever... if you're still on v5.3, you won't be using the Six template.

9 hours ago, joel_pixelplow said:

I'm not sure if the hooks were named something different back in the earlier releases, or if I'm just not finding the right one to accomplish what I am doing.

there are a lot more now than there would have been back in 2013 - ClientAreaPage would have existed back then, but wouldn't help with your situation... as I said, for your issue, just edit the template with the above code and the problem is solved.

9 hours ago, joel_pixelplow said:

I've also seen conflicting help docs that indicate multiple areas where a 'hooks' related .php file can be placed, so any pointers on that would be appreciated as well.

even back in v5, hooks were uploaded to /includes/hooks - just as they still are.

9 hours ago, joel_pixelplow said:

I'm also interested in knowing how to query info from the db inside of WHMCS, as the provided 'Capsule DBAL' seems to also not be working.

Capsule wasn't included until v6 and was an alternative to the deprecated database functionality...

https://docs.whmcs.com/SQL_Helper_Functions

9 hours ago, joel_pixelplow said:

P.S. - Yes, we're planning an upgrade to the latest release, but we're a bit up the road from that task still.

then let me give you two pieces of advice...

  1. if your employer gets their WHMCS license direct from WHMCS, tell them to get a free developers license from them - that will give you/them the option to create a test install where you can duplicate your existing v5 WHMCS site, upgrade it to v7 (or whichever version) and iron out all the issues that you will run into - and you WILL definitely run into issues updating v5 to v7 or 8 (if it's later in the year)... that will give you (as it sounds as though you've been handed the poisoned chalice of being responsible for updating  your employers WHMCS!) time to test & learn before updating the main original WHMCS install.
  2. most of the technical development reference documentation will be irrelevant to v5 - so read it, but don't expect much of it to apply to, or work with, v5.
Link to comment
Share on other sites

Thank you  @string and @brian! for your help.

I did end up using the $clientsstats.balance for this issue.

One followup I did have to @string's reply, if I want to use the current logged -in users "userid" in a function for a hook, how would I pull that into it? I have a small php function (bcmul) that I want to run on one of the template pages, but it apparently can't handle the string length I'm trying to accomplish,  but it does work in a hook:

$guidbuild = bcadd(bcmul($loggedin.userid, "xxxxxxxxxxxxxxxxxxxxx"), "xxxxxxxxxxxxxxxxxxxxx");

Thanks again for your help!

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