anderbytes Posted August 1, 2018 Share Posted August 1, 2018 Hello folks, I hope someone can help me. I'm a bit paranoid about organization and good standards of coding, and I've encountered a situation I couldn't find a solution in WHMCS. I have several hooks with needs of constants to define customfields easily, the client ID used for testing, some API key, and other... Today I'm forced to, inside the hook function, declare always the $var being used explicitely across the hook, because if I declare it outside, try to global it inside function, it won't recognize it. Also.. my idea was to have a SINGLE Constants.php outside every hook php file, and have it included. Couldn't make it work either. Has anyone succeded in that? 0 Quote Link to comment Share on other sites More sharing options...
twhiting9275 Posted August 3, 2018 Share Posted August 3, 2018 It sounds like what you need is a custom include file specifically for those things (API key, etc). Typically, something like this would go in the software's configuration file, but WHMCS doesn't like to play nice with other development tools and things will break if you do that. So, you'll want to create your own... Say, call it customconfig.php or something. Then, in all your hooks , you can simply include the file from there, and use global $varname; at the top of the hook function you want to use. If you put customconfig.php in whmcs/includes/hooks, you won't even have to call the file as an include, it should (in theory) be already loaded in. 0 Quote Link to comment Share on other sites More sharing options...
anderbytes Posted August 6, 2018 Author Share Posted August 6, 2018 I've already tried that before. Even after the include, trying to "global" it brings nothing to inside a hook/function. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.