Cara Menambah Login Button di Product Service WHMCS

Posted on

Halo sobat hosterbyte, berikut ini adalah hook untuk menambahkan login button pada pages Product Service WHMCS. Untuk contoh tampilannya seperti berikut


  • Buat file hook dengan nama AutoLoginToAnyPanelFromMyServices.php dengan lokasi
    folder-whmcs/include/hooksCopy kode berikut<?php

    * Auto-Login to cPanel/Plesk from My Services
    * @package WHMCS
    * @copyright Katamaze
    * @link
    * @author Davide Mantenuto <[email protected]>

    // IMPORTANT! The hook requires changes to two template files. Read the following for instructions

    use WHMCS\Database\Capsule;

    add_hook(‘ClientAreaPage’, 1, function($vars)
    if ($vars[‘filename’] == ‘clientarea’ AND $_GET[‘action’] == ‘services’ AND $_SESSION[‘uid’])
    $productIDs = Capsule::select(Capsule::raw(‘SELECT, t2.type FROM tblhosting AS t1 LEFT JOIN tblservers AS t2 ON t1.server = WHERE t1.userid = ‘ . $_SESSION[‘uid’] . ‘ AND t1.server != “0” AND t1.domainstatus IN (“Active”, “Suspended”) AND t1.username != “” AND t1.password != “” AND t2.type != “”‘));

    foreach ($productIDs as $v)
    $output[‘kt_autologin’][$v->id] = $v;

    return $output;
    elseif ($vars[‘filename’] == ‘clientarea’ AND $_GET[‘action’] == ‘productdetails’ AND $_GET[‘id’] AND $_GET[‘autologin’])
    $product = Capsule::select(Capsule::raw(‘SELECT t2.type FROM tblhosting AS t1 LEFT JOIN tblservers AS t2 ON t1.server = WHERE = ‘ . $_GET[‘id’] . ‘ AND t1.server != “0” AND t1.domainstatus IN (“Active”, “Suspended”) AND t1.username IS NOT NULL AND t1.password IS NOT NULL AND t2.type IS NOT NULL LIMIT 1’))[0];

    switch ($product->type)
    case ‘cpanel’: header(‘Location: clientarea.php?action=productdetails&id=’ . $_GET[‘id’] . ‘&dosinglesignon=1’); die(); break;

    add_hook(‘ClientAreaHeadOutput’, 1, function($vars)
    if ($vars[‘filename’] == ‘clientarea’ AND $_GET[‘action’] == ‘productdetails’ AND $_GET[‘id’] AND $_GET[‘autologin’])
    return <<<HTML
    body {
    <script type=”text/javascript”>
    $(document).ready(function() {
    $(“#domain form”).removeAttr(‘target’);
    $(“#domain form”).submit();

  • Cari file clientareaproducts.tpl pada folderwhmcs/templetes/{namafolder-template}/
    Note : jangan lupa backup file asli sebelum dilakukan editing
  • ganti isinya dengan kode berikut{include file=”$template/includes/tablelist.tpl” tableName=”ServicesList” filterColumn=”4″ noSortColumns=”0″}<script>
    jQuery(document).ready(function() {
    var table = jQuery(‘#tableServicesList’).show().DataTable();

    {if $orderby == ‘product’}
    table.order([1, ‘{$sort}’], [4, ‘asc’]);
    {elseif $orderby == ‘amount’ || $orderby == ‘billingcycle’}
    table.order(2, ‘{$sort}’);
    {elseif $orderby == ‘nextduedate’}
    table.order(3, ‘{$sort}’);
    {elseif $orderby == ‘domainstatus’}
    table.order(4, ‘{$sort}’);

    <div class=”table-container clearfix”>
    <table id=”tableServicesList” class=”table table-list w-hidden”>
    <th>{lang key=’orderproduct’}</th>
    <th>{lang key=’clientareaaddonpricing’}</th>
    <th>{lang key=’clientareahostingnextduedate’}</th>
    <th>{lang key=’clientareastatus’}</th>
    <th> Login Panel </th>
    {foreach $services as $service}
    <tr onclick=”clickableSafeRedirect(event, ‘clientarea.php?action=productdetails&amp;id={$}’, false)”>
    <td class=”py-0 text-center{if $service.sslStatus} ssl-info{/if}” data-element-id=”{$}” data-type=”service”{if $service.domain} data-domain=”{$service.domain}”{/if}>
    {if $service.sslStatus}
    <img src=”{$service.sslStatus->getImagePath()}” data-toggle=”tooltip” title=”{$service.sslStatus->getTooltipContent()}” class=”{$service.sslStatus->getClass()}” width=”25″>
    {elseif !$service.isActive}
    <img src=”{$BASE_PATH_IMG}/ssl/ssl-inactive-domain.png” data-toggle=”tooltip” title=”{lang key=’sslState.sslInactiveService’}” width=”25″>
    <td><strong>{$service.product}</strong>{if $service.domain}<br /><a href=”http://{$service.domain}” target=”_blank”>{$service.domain}</a>{else}<br />-{/if}</td>
    <td class=”text-center” data-order=”{$service.amountnum}”>{$service.amount} <small class=”text-muted”>{$service.billingcycle}</small></td>
    <td class=”text-center”><span class=”w-hidden”>{$service.normalisedNextDueDate}</span>{$service.nextduedate}</td>
    <td class=”text-center”><span class=”label status status-{$service.status|strtolower}”>{$service.statustext}</span></td>
    <td class=”text-center”>
    {if $kt_autologin[$]}
    <div class=”btn-group btn-group-sm plesk-login” style=”width:60px;”>
    <a href=”clientarea.php?action=productdetails&id={$}&autologin=1″ target=”_blank” class=”btn btn-primary btn-xs” alt=”Click to Login Panel” title=”Click to Login Panel” style=”padding: 2px 5px;”><i class=”fa fa-sign-in fa-fw” aria-hidden=”true”></i></a>

    <div class=”text-center” id=”tableLoading”>
    <p><i class=”fas fa-spinner fa-spin”></i> {lang key=’loading’}</p>

  • Kemudian Save
  • Dan lihat hasilnya

Selamat mencoba

  • Referensi :–plesk-login-button-in-my-services