Jump to content

Search the Community

Showing results for tags 'hooks'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • WHMCS Beta Program
    • WHMCS 8.5 Beta Discussion Board
  • The latest WHMCS Release
  • The Latest from the WHMCS Team
  • WHMCS.Community
    • Community Announcements
    • Introduce Yourself
  • Using WHMCS
    • Pre-Sales Questions
    • Admin & Configuration Questions
    • Installation, Upgrade, and Import Support
    • Using WHMCS
    • Troubleshooting Issues
    • Vendor Discussions
  • WHMCS Showcase
    • Showcase Your Site
    • Share Your Best Practices & Tips
  • Developing & Extending WHMCS
    • Third Party Add-ons
    • Service Offers & Requests
    • Developer Corner
    • Building Modules
    • Share Ideas for WHMCS Modules
  • Community Competitions
    • News, Announcements & Blogs from WHMCS
    • Competitions
  • General Discussions
    • General Discussion
  • General Feedback & Assistance
    • Feedback
    • WHMCS.Community Tips & Tricks
  • Third Party Developers's Topics
  • Turkish International Discussions's Topics
  • Russian International Discussions's Topics
  • Spanish International Discussions's Topics
  • Portuguese International Discussions's Topics
  • French International Discussions's Topics
  • Italian International Discussions's Topics
  • German International Discussions's Topics
  • WHMCS Brasil's Topics
  • WHMCS Brasil's Tópicos
  • ModulesGarden Club's Topics
  • Hungarian International Discussions's Segítség
  • ThemeMetro Club's Topics
  • WHMCS Services Club's Topics
  • WHMCS Global Services Club's Topics
  • Katamaze's Free Scripts
  • Katamaze's Module Support
  • Zomex Club's Topics
  • 0100Dev Club's Topics

WHMCS Version

  • V8.4.x Hotfixes
  • V8.3.x Hotfixes
  • V8.2.x Hotfixes

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



About Me

Found 66 results

  1. Is it impossible to access the product ID from the `ShoppingCartValidateDomain` hook? From what I read, that seems to be the case... That would mean that it's impossible to validate the domain differently based on what product is being ordered... right? I'm already validating the domain in the `ShoppingCartValidateCheckout` hook as well, and that works fine as I can access the `pid` in the session variable each item in the cart. But, I'd like to run the validation at an earlier step if at all possible, and prevent them from even adding the item to their cart.
  2. Hi, I'm writing this post because i have problems when i use my hook. I have tested all the things we can do with hooks and I have the same ending and a similar errors . For an exemple and show you what was the problem, I took the hook who can move down an child item. That doesn't work corretly and the site crashes. I'm putting here the error message : Error: Call to a member function getChild() on null in /var/www/html/includes/hooks/testhook.php:6 Stack trace: #0 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Hook/Manager.php(0): WHMCS\Utility\SafeInclude::{closure}() #1 /var/www/html/vendor/illuminate/support/Facades/Facade.php(261): WHMCS\Hook\Manager->run() #2 /var/www/html/includes/functions.php(0): Illuminate\Support\Facades\Facade::__callStatic() #3 /var/www/html/vendor/whmcs/whmcs-foundation/lib/ClientArea.php(0): run_hook() #4 /var/www/html/vendor/whmcs/whmcs-foundation/lib/ClientArea.php(0): WHMCS\ClientArea->outputWithoutExit() #5 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Http/Message/AbstractViewableResponse.php(0): WHMCS\ClientArea->getOutputContent() #6 /var/www/html/vendor/laminas/laminas-httphandlerrunner/src/Emitter/SapiEmitter.php(41): WHMCS\Http\Message\AbstractViewableResponse->getBody() #7 /var/www/html/vendor/laminas/laminas-httphandlerrunner/src/Emitter/SapiEmitter.php(31): Laminas\HttpHandlerRunner\Emitter\SapiEmitter->emitBody() #8 /var/www/html/clientarea.php(0): Laminas\HttpHandlerRunner\Emitter\SapiEmitter->emit() #9 {main} I followed this doc https://developers.whmcs.com/themes/navigation/ I'm entering correctly the name of menu items but I don't know why that doesn't works. Here is my code if somebody could help me : use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $primarySidebar->getChild('Account')->getChild('Edit Account Details')->moveUp(); });
  3. Hi, I have some code executed in the hook "ShoppingCartCheckoutCompletePage" with no problems. The code reads some client data based on the orderid stored in the database. But when i change the setting in "General Settings > Ordering > Auto Redirect on Checkout" to "Automatically take the user to the invoice" or "Automatically forward the user to the payment gateway" then the hook is normally not fired. Is there another hook i can use or another technique that will execute my code when the order is completed and stored in the database? Thanks.
  4. Starting from the code provided by @brian! in this post: I realized a pop-up system which shows every time user log-in, but once a day (that's to say: if the user login 5 or more times in a day, the pop-up shows just one time, in order not to annoy him) The pop-up shows to the user his previous log-in time, and one "trick of the day" (randomly chosen one) (IMHO, "trick of the day" is a great way to spread knowledge and marketing news without annoying the user) The code, in form of a hook (note: line #35 is for testing purposes only: remove or comment it): <?php //Show modal popup to clients, with a welcome message and a random trick of the day //original code by brian! , modified by Remitur function client_custom_headoutput_hook($vars) { $head_return = ''; $head_return = '<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script> <script> $(document).ready(function() { $(\'#myModal\').appendTo("body"); function show_modal(){ $(\'#myModal\').modal(); } window.setTimeout(show_modal, 100); $(".dismiss").click(function() {}); }); </script>'; return $head_return; } add_hook("ClientAreaHeadOutput",1,"client_custom_headoutput_hook"); use Carbon\Carbon; function client_custom_headeroutput_hook($vars) { $client = Menu::context('client'); $lastlogin = Carbon::parse($client->lastLoginDate); $enddate = Carbon::parse($client->lastLoginDate)->addDays(1); // next line is just for testing purposes: remove it! $enddate = Carbon::today(); $today = Carbon::today(); $templatefile = $vars['templatefile']; if (empty($client->id)) { return; } if ($today >= $enddate and $templatefile == "clientareahome") { $header_return = ''; $header_return = '<div class="container"> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog modal-md"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title"><i class="fa fa-thumbs-up fa-lg"></i> '.Lang::trans('hello').', '.$client->firstname.'</h4> <p>Your last login has been '.$lastlogin.'</p> </div> <div class="modal-body"> <p>Trick of the day:</p> <p>'.Lang::trans ('tricks.'.rand(1,13)).'</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary dismiss" data-dismiss="modal">'.Lang::trans('orderForm.close').'</button> </div> </div> </div> </div> </div>'; return $header_return; } } add_hook("ClientAreaHeaderOutput",1,"client_custom_headeroutput_hook"); The tricks are provided as an array of language variables; here there're 13, I guess that 30 is the minimum reasonable number; more is better. In the tricks you can provide also internal and external links (just one here for example): #====================== tricks for popup ============================================ $_LANG['tricks']['1'] = "On DomainRegister you can register your own .com.br domain even if you have not a headquarter in Brazil"; $_LANG['tricks']['2'] = "Interface on DomainRegister is available in three different languages (English, Italian and Slovenian): select your preferred one using the flags in the upper right corner "; $_LANG['tricks']['3'] = "On DomainRegister you can renew any domain up to 10 years in advance (even those for which a multi-year renewal is not envisaged)"; $_LANG['tricks']['4'] = "If you manage a large number of domains, on DomainRegister you can create one or more DNS templates, to quickly implement complex DNS configurations for each single domain "; $_LANG['tricks']['5'] = "Using wildcard SSL certificates, with a single SSL certificate you can secure both your main domain and an unlimited number of subdomains on any number of different servers"; $_LANG['tricks']['6'] = "<a href=\"https://domainregister.international/dns-service.php\" target=\"_blank\">DomainRegister's DNS service</a> (which is free for any domain registered through us) got 100% uptime... since 2011!"; $_LANG['tricks']['7'] = "If you change the data of the registrant of a .com domain, you cannot transfer the domain for 60 days (sixty days lock)"; $_LANG['tricks']['8'] = "With DomainRegister's Linux Pro hosting plan, you get your own, dedicate european IP for your site"; $_LANG['tricks']['9'] = "DomainRegister's StarterMail starts with 5 email addresses and 5 GB archive space, and may be expanded up to 25 email addresses and 25 GB archive space; larger solutions are available upon request"; $_LANG['tricks']['10'] = "Keep your domains and services safe by protecting them with 2FA authentication: on DomainRegister it's free!"; $_LANG['tricks']['11'] = "trick 11"; $_LANG['tricks']['12'] = "trick 12"; $_LANG['tricks']['13'] = "trick 13"; Any idea to improve this hook is welcome!
  5. I want to remove the "Quick Shortcuts" from: Client Area > My Products & Services > Product Details I'm trying with this hook code, but no luck: # remove the "Quick Shorcuts" from the Client Portal > Product Details add_hook('ClientAreaPageProductDetails', 1, function($vars) { return "<style> .cPanelQuickShortcutsPanel {display: none;} </style>" });
  6. Hi, I am looking for a way to determine the source of a new invoice. That being is the new invoice generated by a client action, like ordering a service. Or if it simply is generated by billing. Testing the InvoiceCreated hook for invoiceID gives us the new invoice number. However it is not possible to check this invoiceID against database tables. This seems to be because the invoice has yet to be finalized. Else we could have checked if the invoiceID was located in both tblorders.invoiceid and tblinvoices.id. Any match on both tables would indicate it was an order, and should there only be a match in tblinvoices.id it would be simply billing. Next we have the source variable, there it seems to be mainly autogen being used. I did check the classdoc for Invoice, there we have a runCreationHooks method with a String $source parameter, with 4 possible options: 'adminarea', 'api', 'autogen' or 'clientarea'. Now the whmcs hook InvoiceCreated states that the only values it will return are one of 'adminarea', 'api', 'autogen' or 'clientarea'. Does anyone have any tips, or have you perhaps dealt with this issue and found a way?
  7. Hello, how can i add knowledgebase links related to query on any ticket created by user? screenshot added for reference. https://prnt.sc/1vk8w53
  8. Hello, I have a hook that redirects the Home navigation from Portal home to my Homepage: use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Home'))) { $primaryNavbar->getChild('Home') ->setURI('../'); } }); But can't find a hook to change when a user clicks on the Icon in the Header to also change it to homepage and not to the Portal home. Been looking for hours now, but no luck.
  9. Hello all. I am hoping you can help me do what I think should be simple for people who have dealt with hooks already. I want to do this: IF a product's ID = x (I imagine this involves getting the product ID from a variable and doing an IF statement in PHP) THEN get the service_domain field (built-in field, not custom field), run a shell script while passing the domain field as a bash variable to be used within the script's execution. Why do I want to do this? This will allow me to begin the process of provisioning maintenance coverage via WP CLI for customers who order a maintenance plan from us. I'll create an additional 2 hooks -- three total so one for each maintenance plan. If I can get the first hook, i can make the others and likely merge them together. I just need a "template" to follow from someone who understands PHP more than on the surface like I do. This ultimately will chain 3 of my servers together. WHMCS server, our cPanel server, and the maintenance server. Any help is appreciated. Would anyone be willing to paste in an effective code sample that I can use?
  10. Hi, does anyone has a Hook which auto enables the DNS of new Domains in WHMCS? Customers always complaining that DNS Management is missing and i have to switch that on, all the Time. And i wont take this as upselling position. So activate DNS Management in Frontend for "0$" is aswell not suitable for me. It just be there and done 🙂 Any Suggestions, or Code Templates?
  11. Hello, I created a hook file for the 'OrderPaid' event and it seems like the $vars variable that is being passed to it always comes up empty. Does anyone know why this is happening?
  12. Hello, I created a hook file for one of my addon modules and it seems like the hook event is always happening. The hook event is 'OrderPaid'. When I look at the module logs there is an entry for this hook event every minute even though no orders have been paid for during this time. I need to know why this is happening. If anyone can help me I would appreciate it.
  13. Hi there, I have returned $vars from EmailPreSend Hooks like this Array ( [messagename] => Other Product/Service Welcome Email [relid] => 805 [mergefields] => Array ( [service_first_payment_amount] => WHMCS\View\Formatter\Price Object ( [price:protected] => 350000 [currency:protected] => Array ( [id] => 1 [code] => IDR [prefix] => Rp [suffix] => IDR [format] => 3 [rate] => 1.00000 ) [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX} [defaultCurrencyDescriptor:protected] => Array ( [format] => 1 [prefix] => [suffix] => ) ) How to print "350000" on price protected object from ['mergefields']['service_first_payment_amount'] I try $vars['mergefields']['service_first_payment_amount']->price; But i get message Error: Cannot access protected property WHMCS\View\Formatter\Price::$price
  14. Hi all! I'm writing an Add-on and am trying to hook to UserEdit, but I'm finding that in My Profile (client area) there are 2 'SAVE' buttons: Top for the name, bottom for the email. A simple logging statement at the beginning of the hook declaration in my hooks.php file is showing that the hook is called as expected with the TOP SAVE button, but not on the BOTTOM ??? Can somebody please confirm if this is a bug or a problem with my installation and how to troubleshoot it? I'm on v8.1.0-release.1 Thank you in advance.
  15. Dear All, I want to show the Next Invoice Date under Next Due Date when admin access Page Client Details on Product/Services Tab. But, I've no idea how to show it, I just know to get the Next Invoice Date value related from tblhosting Anyone can help me to show it ? Thank you. <?php use WHMCS\Database\Capsule; add_hook('AdminClientServicesTabFields', 1, function($vars) { $PID = $vars['id']; $nextinvoicedate = Capsule::table('tblhosting')->where('id', $PID)->pluck('nextinvoicedate'); $result = array(); $result['nextinvoicedate'] = $nextinvoicedate; return $result });
  16. Hi all, I wish to perform some registrar API activities in the registrar hooks, but as the hook's vars or params didn't provide credential details, I tried to get direct from DB Capsule and unfortunately noticed the data stored in encrypted format... Any suggestions to over come this? TQ. Best Regards, Nelson
  17. Is there any way I can create a Custom Page just for product details using hooks. Example: I offer 3 SSL Certificates as products. Under my Order Now button , I have a " Details Page" link/button. On clicking the link I am redirected to a custom Page which displays all the details about my selected product. Is there an option to add Long Description(new column) to every product and display it in my custom Page. How can i achieve it using Hooks? P.S : I didnt find any useful links from internet.
  18. Hello, I am working on a custom hook and I find that just by adding an input field of type Tel, the country code is added by WHMCS. I am basically showing a modal from my hook if a condition is met. Now I am testing the example code on the IntlTelInput plugin website (https://intl-tel-input.com/node_modules/intl-tel-input/examples/gen/default-country-ip.html) $(document).ready(function(){ var input = document.querySelector("#phone"); window.intlTelInput(input, { initialCountry: "auto", geoIpLookup: function(callback) { $.get("https://ipinfo.io", function() {}, "jsonp").always(function(resp) { var countryCode = (resp && resp.country) ? resp.country : "us"; callback(countryCode); }); }, }); }); <input type="tel" id="phone"> But that's returning an error: I basically want to sow the local country code in the form. is there a way to achieve this? bearing in mind that I am not in the tpl file, just echoing a modal from my hook.
  19. Dear All, My Product setting Configuration Prorate Date: 1 Charge Next Month: 32 So, every product that client buy will have Next Due Date value on tblhosting 01/mm/yyyy on each month My Goal: I want to make all Invoices that created by automatic cron (recurring invoice, etc) and publish to client have a duedate value 10/mm/yyyy The Next Due Date from tblhosting do not need to be change, because I need the product period date is 1 until the end of the date of that billed month. Is it possible to do that by create Hooks ? If yes, which Hooks variable that I need to use to achieve it ? If due date value from tblinvoices can be overwrite by hook, does the invoice reminder cron will follow the new due date ?
  20. sometimes the client can have 2 emails. one for your account details and one for the account owner. I need to know if the account owner's email is verified. The var: $client = Menu::context("client"); gets the email that the customer has in the account details, however this is not the email owner of the account. I hope to make myself understood correctly.
  21. Hi Community, I have been trying to figure something out for a while now and am at the end of the road. We have a block of JavaScript which we wish to execute on any page where the user has got a certain product active. If they don't have the certain product, nothing should happen, but if they do, I want the JavaScript to execute. I was thinking that a hook might be the best way to accomplish this, but I am unsure of how to make this work? Any suggestions or ideas would be massively appreciated. Many thanks, Sam
  22. Hello, I am new to this community! I am setting up a hook that allows me to pass new client data to Zapier in order to update our Marketing automation software. This is the code I have been testing now: add_hook('ClientAdd', 1, function ($vars) { $userid = $vars['userid']; $firstname = $vars['firstname']; $lastname = $vars['lastname']; $email = $vars['email']; $phone = $vars['phonenumber']; $city = $vars['city']; $country = $vars['country']; $postcode = $vars['postcode']; $company = $vars['companyname']; $state = $vars['state']; $params = '?userid='.$userid.'&firstname='.$firstname.'&lastname='.$lastname.'&email='.$email.'&phonenumber='.$phone.'&city='.$city.'&country='.$country.'&postcode='.$postcode.'&companyname='.$company.'&state='.$state.'&source=WHMCS'; $url = 'https://hooks.zapier.com/hooks/catch/zzz/rrrr/'.$params; $options = array( 'CURLOPT_POST' => 0 ); $response = curlCall($url,$postfields,$options); logActivity('logged addClient with params: ' . $params . 'following is the result: ' . $request, $userid); }); I also tried to send this via file_get_contents but it does not seem to work, by composing the url together with real world values gotten from the LOG in the admin area the request works on Zapier's end, I suppose that the problem lies within WHMCS and the request. The Zapier request has been altered for privacy reasons. Can anyone point me in the right direction?
  23. Hi, I've been unable to find other posts on the topic, should there be any I am sorry for posting. I am looking for a way to place orders that will be flagged as fraud. This is in order to test some post fraud check hooks. I have tried Maxmind/Fraudlabs with bogus zip codes, hotmail email, high risk countries. Orders just pass trough as OK. If anyone has any suggestions as to triggering fraud check with automatic listing as fraud-order please share. Setting a order to fraud manually is not an option, as certain hooks does not trigger with this behavior. Cheers
  24. Hello, I am creating a module for invoice to display data from database. I want to know how to add that fetch value from module to invoice using hooks.
  25. how to get user request module info into modules hook folder structure: mymedia | | +---- hooks.php +---- mymedia.php +---- index.php created products: product-01: product-02: ------------------- ------------------- | Name: media 01 | | Name: media 02 | | Module: mymedia | | Module: mymedia | | | | | |_________________| |_________________| here, TableName: tblproducts ----------------------------------------------------- | id | name | servertype | ...... | ------------------------------------------------------- | 1 | media 01 | mymedia | ...... | | 2 | media 02 | mymedia | ...... | | .. | ........... | ....... | ...... | ----------------------------------------------------- hooks.php: <?php add_hook("AcceptOrder", 0, "mymedia_acceptOrder"); function mymedia_acceptOrder() { // how to get request product id or name here $mediaIDorName = ?? } ?> NB: how to get user request module info into modules hook.
  • 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