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.Community

  • The latest WHMCS Release
  • The Latest from the WHMCS Team
    • News & Announcements
  • 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 Beta Program
  • 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
    • Competitions
  • General Discussions
    • General Discussion
  • General Feedback & Assistance
    • 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 Argomenti
  • 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

WHMCS Version

  • V7 Hotfixes
  • V7.1.x Hotfixes
  • V7.2.x Hotfixes
  • V7.3.x Hotfixes
  • V7.4.x Hotfixes
  • V7.5.x Hotfixes
  • V7.6.x Hotfixes

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 35 results

  1. Cubeboy

    Client area panels

    I need to get rid of the date when I add files on the admin side. when I upload a file the a clients account in the admin section, it displays in the client area and it time stamps it. how can I remove the time stamp? OR remove the whole hook and add it back with my own var? <?php use WHMCS\View\Menu\Item; add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels) { $homePagePanels->removeChild('your files:dateadded'); });
  2. I found an older post regarding this but I wanted to post a working hook that adds recaptcha to the checkout page. I think this a great thing especially if you're being bombarded with fake accounts and orders. /includes/hooks/checkout-recaptcha.php: <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function limitOrders($vars) { $url = 'https://www.google.com/recaptcha/api/siteverify'; $privatekey = "YOUR_RECAPTCHA_SECRET_KEY_HERE"; $response = file_get_contents($url . "?secret=" . $privatekey . "&response=" . $_POST['g-recaptcha-response'] . "&remoteip=" . $_SERVER['REMOTE_ADDR']); $data = json_decode($response); if (isset($data->success) AND $data->success == true) { // everything is ok! } else { $pm = $vars['paymentmethod']; if ($pm == "paypalpaymentspro") { global $errormessage; $errormessage.= "<li> Please, confirm that you are not a robot! <br/></li>"; } //if CC } } //function add_hook("ShoppingCartValidateCheckout", 1, "limitOrders"); Change YOUR_RECAPTCHA_SECRET_KEY_HERE to your the recaptcha private/secret key Google gives you. I'm using for my credit card checkout which is "paypalpaymentspro" but you can use it for any payment method. I think you really only need if you accept credits though. To get your payment method view source on the checkout page and search for "paymentmethod" your payment method will be near this. In your checkout.tpl file you also need to add somewhere under the "Complete Payment" button: <div class="g-recaptcha" data-sitekey="YOUR_RECAPTCHA_PUBLIC_KEY_HERE"></div> Replace YOUR_RECAPTCHA_PUBLIC_KEY_HERE with your public recaptcha key provided by Google. This is tested working on WHMCS v7.5.1.
  3. When it comes time to order a hosting plan, sometimes you don't want your users to be able to enter in a subdomain when using an existing domain for their order. In this post I am going to walk you through a basic hook that prevents entering a subdomain by using some client-side JavaScript. Our first order of business will be to check out the WHMCS hooks index to see if there is a hook point that will fit our needs: https://developers.whmcs.com/hooks/hook-index/ It turns out, the ClientAreaFooterOutput hook will do nicely: https://developers.whmcs.com/hooks-reference/output/#clientareafooteroutput The reason for this is because that hook point will allow you to inject HTML code, which also can contain JavaScript, into the client-side template so you can make the magic happen. Before getting into more detail, let's go ahead and dive right into the code. You can also download it from this link block_subdomains.txt (then rename the extension to .php). Here is the entire snippet: <?php add_hook('ClientAreaFooterOutput', 1, function($vars) { $jqueryCode = '<script> $("#owndomainsld").on("keyup", function(e) { var str = $("#owndomainsld").val(); if ( str.indexOf(".") != -1 ) { $("#owndomainsld").val(""); alert("Subdomains are not allowed!"); } }); </script>'; if (strpos($_SERVER['REQUEST_URI'], 'cart.php') !== false ) { return $jqueryCode; } }); The first thing to notice is the add_hook function is being called with the ClientAreaFooterOutput hook point as the first argument and an anonymous function as the second argument. The anonymous function also has a $vars variable being passed into it. For this example the $vars variable is not actually being used in the body of the function, but it does contain some useful parameters should you need to access them. Those parameters can be found in the documentation for the hook point linked above. The next thing to notice is the $jqueryCode variable. which is actually a PHP string that contains the JavaScript code we will be injecting into our client-side page. Since WHMCS uses the jQuery JavaScript library and loads it on the page, we can use it in our code. First, we need to bind an event listener to the keyup event on the domain text box and provide it a callback function to execute when that event occurs. This can be easily done by targeting the element's HTML ID attribute. That is what is happening here: $("#owndomainsld").on("keyup", function(e) {... After that, the value of the domain text field is stored in a JavaScript variable called str. Since this code is inside our callback function, it will be executed every time the user presses a key on the keyboard and then releases it: var str = $("#owndomainsld").val(); Once we have that text stored in our str variable, we need to check it for a dot or period '.' character to see if it is a subdomain. This can be done with indexOf string function in JavaScript. If the text appears to be a subdomain, we'll go ahead and empty out the text field and then show an alert to the user to let them know that subdomains are not allowed: if ( str.indexOf(".") != -1 ) { $("#owndomainsld").val(""); alert("Subdomains are not allowed!"); } Finally, the last part of the hook does a case-insensitive string search on the $_SERVER['REQUEST_URI'] (the URL of the page you're visiting), to check and see if a cart page is being rendered. If a cart page is detected, the JavaScript code is injected into that page so it can run. if (strpos($_SERVER['REQUEST_URI'], 'cart.php') !== false ) { return $jqueryCode; } Putting it all together, we get the final results in WHMCS which look like the picture here: I hope this post proved helpful and gives some insight on some of the ways that WHMCS can be extended to do many different things outside the box! At the time of writing this post, this hook was tested on the latest stable release of WHMCS 7.4.2 and should work with any that fall under Active Support as per the LTS schedule here: https://docs.whmcs.com/Long_Term_Support#WHMCS_Version_.26_LTS_Schedule If you have any feedback, questions, or concerns that I did not cover in this post, please feel free to reach out!
  4. Hi All, Has anyone had any experience with a hook updating an invoice? I want to use InvoicePaidPreEmail to append a credit card fee to the invoice. I understand WHMCS is not willing to budge on per Gateway charges, but I can disclose to my customers that there is a credit card fee of x% and then send the right payment value to the bank, once it returns as approved I can then append it to the invoice and prior to the email being sent it will now include the charge on the invoice. Any help with this is appreciated.
  5. I've created a provisioning module for v7.3.0 and I'm using the following to remove the Change Password button from the Module Command area in admin but it isn't working: add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if(null !== $primarySidebar->getChild('Service Details Actions')) { $primarySidebar->getChild('Service Details Actions') ->removeChild('Change Password'); } }); Why isn't this working? It looks right to me.
  6. Hello, I have put the hook with the code below in the directory /includes/hooks/: ------------------------------------------------------------------ <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $urlidr = $vars['clientsdetails']['customfields15']; if (!is_null($primaryNavbar->getChild('Services'))&&!is_null($urlidr)) { $primaryNavbar->getChild('Services') ->addChild('Emergency Contacts', array( 'label' => Lang::trans('buyResellerWebsite'), 'uri' => $systemurl.'cart.php?a=add&pid='.$urlidr, 'order' => '100', )); } }); ------------------------------------------------------------------ The issue is that the variable $urlidr = $vars['clientsdetails']['customfields15'] remains empty, even though listed among those in the page with {debug} in the file clientareahome.tpl. Anyone can help me, please? Thanks.
  7. CrunchyToast

    A couple dev questions

    Hey everyone, Working on a few different modules and had a couple questions. Is there an action hook that allows you to run a cron job every time the WHMCS is called? For example, my WHMCS cron file runs every 5 minutes. Is there a hook or a way I could have a custom hook or script run every time the actual cron runs? All the hooks I see currently only run once a day. Is there a way to add another tab to the client detail page in the admin panel via hook or another method without having to customize the template? Thank you ahead of time.
  8. Hello, We need a customization for ResellerClub (by hooks). We need the module to work exactly as it does the official WHMCS module but with the following customizations: If the country used in the customer's personal data is Cuba. Then the data to be used at the time of registering / transferring the domain is the company data used for the administrative and billing contact (those selected in the domain tab of the general configuration of WHMCS) or other saved in the hooks file. In other words, if the client is from Cuba, then the domains for this client are registered in favor of our company and not in favor of the client. If the client is from Cuba, then he does not have the possibility to modify the WHOIS data of the domain from his client area. For customers from other countries the module should function exactly like the official module. According to WHMCS this can be done by Hooks. Bellow the WHMCS suggestion: We are waiting for some developer who wants to help us in this matter. Greetings
  9. I can seem to find where in the hooks files you would add another link to show up in the account section of the top menu. https://webhost.pro/index.php It looks like it's called: TMSecondaryNavbar.php But when I add a new hook there nothing adds to the menu. Thanks, Charley
  10. The silly documentaion doesn't talk about this and many other questions, which have to be asked here, on the forums and are bothering other members, just because of the poor documentation. It has been asked xx times here like below, but in the documentation you won't find the answer: https://forum.whmcs.com/showthread.php?105202-v6-02-Menu-How-to-add-Link-Target-Attribute&p=433370#post433370
  11. lunaticnoise

    Strange hooks behaviour

    Hello, I have a file /includes/hooks/hooks.php with the following code: <?php add_hook('ClientAreaPage', 1, function($vars) { var_dump("ClientAreaPage"); }); add_hook('AdminAreaPage', 1, function($vars) { var_dump("AdminAreaPage"); }); add_hook('PreRegistrarGetDNS', 1, function($vars) { var_dump("PreRegistrarGetDNS"); }); add_hook('AfterRegistrarGetDNS', 1, function($vars) { var_dump("AfterRegistrarGetDNS"); }); add_hook('PreRegistrarSaveNameservers', 1, function($vars) { var_dump("PreRegistrarSaveNameservers"); }); add_hook('AfterRegistrarSaveNameservers', 1, function($vars) { var_dump("AfterRegistrarSaveNameservers"); }); add_hook('AfterRegistrarGetContactDetails', 1, function($vars) { var_dump("AfterRegistrarGetContactDetails"); }); add_hook('PreRegistrarGetContactDetails', 1, function($vars) { var_dump("PreRegistrarGetContactDetails"); }); I am trying to execute some of the above hooks, but only ClientAreaPage and AdminAreaPage are called when I visit any page of clientside or adminside. I know that PreRegistrarGetDNS, AfterRegistrarGetDNS, PreRegistrarSaveNameservers, AfterRegistrarSaveNameservers, AfterRegistrarGetContactDetails and PreRegistrarGetContactDetails are only called in few actions, for example when the domain register is getting the nameservers, contact details or saving dns records so I go to any admin domain page to force these hooks but sadly they are never called. I also have few breakpoint in the code but the debuger only stops at ClientAreaPage and AdminAreaPage hooks. Is anyone having this issue? My WHMCS version is 7.1.1
  12. Hi, I am trying to create a custom sidebar, to appear only on the domains list page of the client area. I have created a custom hook file in /includes/hooks/. Firstly, I'm wrapping the 'ClientAreaSecondarySidebar' hook in a conditional statement, so it's only displayed on the Client Area Domains page ($templatefile = 'clientareadomains'). Is this the correct way to get the current page / template file being viewed? if (App::getCurrentFilename() == 'clientarea' && $_GET['action'] == 'domains') { ... } Is there a better way to do this? I tried just using $templatefile, but it's not available. Next, I am creating a new secondary sidebar. I have created some client custom fields in WHMCS Admin and I can see them in the Smarty template debug, they are included in the $clientsdetails array as 'customfields2' and 'customfields3' -- how do I access these in my hook? This is what I've tried, but it doesn't work. use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) { $secondarySidebar->addChild('custom-fields', array( 'label' => 'Custom Fields' ))->moveToBack(); $customFieldsSidebar = $secondarySidebar->getChild('custom-fields'); $customFieldsSidebar->addChild('field1', array( 'label' => $clientsdetails['customfields1'] )); }); Is is possible to get the $clientsdetails array and use it in my hook like this? Any help appreciated. Thank you.
  13. bigideaguy

    WHMCS Slack

    WHMCS Slack allows you to post automatic updates to Slack when events happen in your WHMCS installation you can have an unlimited number of events and an unlimited number of channels. You can even post the same event to multiple channels but with a different message if you would like to. The addon uses WHMCS hooks to post to slack when things happen. The following hooks are available in version 1.0: AddInvoiceLateFee AddInvoicePayment AddTransaction AdminAreaViewQuotePage InvoiceCancelled InvoiceChangeGateway InvoiceCreated InvoicePaid InvoicePaymentReminder InvoiceRefunded InvoiceSplit InvoiceUnpaid LogTransaction ManualRefund QuoteCreated QuoteStatusChange acceptQuote AcceptOrder AddonFraud AfterShoppingCartCheckout CancelOrder DeleteOrder FraudOrder PendingOrder RunFraudCheck ShoppingCartValidateDomain AdminServiceEdit CancellationRequest ServiceDelete ServiceRecurringCompleted AfterModuleChangePackage AfterModuleChangePassword TicketAdminReply TicketClose TicketOpen TicketStatusChange TicketUserReply When editing a hook you can add a channel and the message format you want to post to that channel. Purchase the addon for only $9.99 via our website at http://anveto.com/members/cart.php?a=add&pid=37 Purchase the addon without the encoding in order to make your own modifications for $49.99 at http://anveto.com/members/cart.php?a=add&pid=38
  14. ducohosting

    Understanding hook priorities

    Hi everyone, I'm working on a module that needs to execute three separate tasks after the daily cron job. They need to be executed in a specific order. However, I'm not sure what to watch out for when programming the hook priorities and haven't found any useful documentation on the matter. My question is simple: Are functions with a lower hook priority executed before or after those of a higher priority? And, are duplicate priorities possible or will this result in an exception? Thanks!
  15. Hello, I want to display a user's recent support tickets in some client area pages. I have created a hook following the instructions here and changes the variables. The hook works fine and it displays the results I need. However, it displays the recent tickets of all users. here is my code <?php function hook_displaysupporttickets($vars){ $output = ""; $query = "SELECT * FROM tbltickets ORDER BY date DESC LIMIT 0,6"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)) { $tid = $data["tid"]; $date = $data["date"]; $replyid = $data["replyid"]; $title = $data["title"]; $department = $data["department"]; $date = fromMySQLDate($date); $output .= '<p class="mytitleannoun"><i class="fa fa-file-text-o" aria-hidden="true" style="margin-right:15px;"></i><a style="margin-right:15px;" href="/viewticket.php?tid='.$tid.'">'.$title.'</a><span>'.$department.'</span><span>'.$tid.'</span><font color="#b3b3b3">'.$date.'</font></p>'; } return array("displaysupporttickets" => $output); } add_hook("ClientAreaPage", 1, "hook_displaysupporttickets"); I need to change the code so that it displays only the tickets of the logged in user (each user will see only his own tickets). Any ideas? Thank you.
  16. How can I show the clients first and last name in a support ticket hook. I got everything else working such as userid, message, and subject. But I can't get the first and last names to show. I tried $firstname and $lastname as a varible but it doesn't show.
  17. I am developing an addon module, and it also uses a hooks.php file. I have two hooks: AdminAreaFooterOutput and AdminAreaHeadOutput. My module also includes a lang/english.php file, and I have that working for the main part of my module, now i need to get it working for the hooks file. I have searched the forums and have found many posts relating to the use of Lang::trans. However, in pretty much all cases it says the language string needs to be added to the Language Overrides files. Since this is a module, I'd like it to work without needing any modifications to the main language overrides files. I would rather use the language files distributed with my module for this purpose. So how can I use the text strings from my module/lang/ folder in my hooks.php file?
  18. Thanks in advance for your time, I appreciate your attention to detail. May you please post estimate plus turnaround? There is no set budget, or specific deadline. I desire, a specific product / service on-purchase, to create new support ticket. • Visitor lands on website and wants to buy "Consultation Service" • Visitor does three things - add product / service to cart - inputs customer data and checks-out - submits successful payment VIA paypal • Visitor receives new email with support ticket link From what I read, @sentq made quality reply, saying developer will need to understand: http://docs.whmcs.com/Hooks http://docs.whmcs.com/Hooks:ShoppingCartCheckoutCompletePage http://docs.whmcs.com/Configuring_Products/Services Once addon module is complete, assuming this is best way to create results, I would like to publish on repo to share with community. If you think that is not best, no problem.
  19. I want to set the ticket status to "Open" whenever a reply is made by an admin, I am doing so because WHMCS do not log the change in ticket status a response is made to the ticket, my idea is to force my staff to change the ticket status through the dropdown. Below is my code for it but I am getting error 500 with this code. <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function set_ticket_open($vars) { $tid = $vars['ticketid']; UPDATE `tbltickets` SET `status`="Open" WHERE `id`="$tid"; } add_hook("TicketAdminReply",1,"set_ticket_open"); ?> Can anyone help me with fixing this code or give me any other code that can log the status change in database according to the status selected during "add response".
  20. earthgirlllc

    Question on add_hook()

    I'm trying to understand hooks -- would someone please tell me what the number 1 represents here: add_hook("ClientAdd",1,"create_forum_account"); I'm sure it's simple, but I'm not finding it in the documentation. Thanks
  21. hello... i have a big problem (i am new in WHMCS) First... what is the difference between create hooks and modules? Second: I want to implement the next process ¿how i can to place the domainchecker of the register or tranfers in the same page of register the contact? that is to say, where you can register and consult a domain all in one page this can to do by hooks or modules? i am confussed
  22. Hi, I have a Hook file that I developed using WHMCS V6 as the testing platform, it works perfectly on 6, but on 5 it throws my entire admin area and WHMCS installation offline. Basically causes the whole WHMCS to crash. I followed the guide here http://docs.whmcs.com/Hooks:ClientAreaPrimaryNavbar and copied & paisted the code over as is to see if I made a mistake, but it keeps giving me the below error: Catchable fatal error: Object of class Closure could not be converted to string in /home/mydomain/public_html/whmcs/includes/hookfunctions.php on line 0 What could be the cause of this? Code Example: add_hook( 'ClientAreaPrimaryNavbar', 1, function($primaryNavbar) { /** @var \WHMCS\View\Menu\Item $primaryNavbar */ $newMenu = $primaryNavbar->addChild( 'uniqueMenuItemName', array( 'name' => 'Home', 'label' => Lang::trans('languageStringVariable'), 'uri' => 'clientarea.php', 'order' => 99, 'icon' => 'fa-calendar-o', ) ); $newMenu->addChild( 'uniqueSubMenuItemName', array( 'name' => 'Item Name 1', 'label' => Lang::trans('languageStringVariable'), 'uri' => 'cart.php', 'order' => 10, 'icon' => 'fa-cart-plus', ) ); } );
  23. Hi folks, I am programming custom module/addon, with hook, which is going to execute when module is activated, and sent a Terms of Use and Contract in PDF to user. But problem, is that hook is running on product change, even delete action. <?php error_reporting(E_ALL); require_once 'functions.php'; function hook_TestExternalFunction($params) { // pokreni renewal funkciju iz samog modula //termsaddon_TestFunction(); } add_hook("PreModuleCreate",1,"hook_TestExternalFunction"); Also, I am curious, code in function.php, which is only included in hooks.php is getting executed, without function call in hook_ definition. Is this expected, or should I explicitly make function call in hook call as follow bellow? File: hooks.php require_once 'functions.php'; function hook_TestExternalFunction($params) { // run function from functions.php termsaddon_TestFunction(); } add_hook("PreModuleCreate",1,"hook_TestExternalFunction"); File: functions.php function termsaddon_TestFunction() { .. do something .. send mail ... }
  24. I am modifying my primary and secondary menu, as suggested in the Editing Client Area Menus documentation. I Want to move the View Cart link down in to the secondary navbar, along with a cart icon and a badge with the number of items. It's that last part I'm stuck with. So far I have this: $secondaryNavbar->addChild('View Cart')->setLabel(Lang::trans('viewcart'))->setUri('/cart.php?a=view')->setOrder(20)->setIcon('fa-shopping-cart')->setBadge('X'); Where 'X' is, I wish to put the cart items count. I see in header.tpl there is $cartitemcount, but I can't seem to find out a way, or even if it's possible, to access this information? I saw in the documentation the use of Lang::trans, so I can only hope there are more available to me. If so, I'd really appreciate a link to the documentation for this - even if it's just general smarty stuff. Many thanks
  25. Hi, Just trying to get some insight on adding a shopping cart icon like on this image to the WHMCS main menu. blog.webhost.pro/wp-content/uploads/2015/11/cart.jpg I can add hooks, I just have no idea how to add a hook next to the menu "account" drop down link. I also am not sure how to add an icon with a number to show how many items are in the shopping cart. I am willing pay for help as well. Any insight will help me. Thanks so much for your time. Charles
×

Important Information

By using this site, you agree to our Terms of Use & Guidelines