Jump to content

How to show hook only in client area home page


Recommended Posts

Hello i have an hook, i want to load/show that hook only on client area home page and on the top of Your Info box.

I have attached and screenshot showing where i want to show my hook, i want to show at the top of Your Info and Login Information option. But want to show only on client area home page. I have attached my current code, can you please correct my code to show hook only on clientarea home page. Here is code :

 

<?php

/**
 * Display Client's Credit Balance in Client Area
 *
 * @author WHMCMS
 * @link   www.whmcms.com
 * @since  WHMCS v6.0.0+
 */

use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;

# Add Balance To Sidebar
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar){

    $filename = basename($_SERVER['REQUEST_URI'], ".php");
    
    $parseFile = explode('.', $filename);
    
    $client = Menu::context("client");
    
    $clientid = intval($client->id);
    
    if ($parseFile['0']!=='clientarea' || $clientid===0){
        return;
    }

    $primarySidebar->addChild('Client-Balance', array(
        'label' => "Available Credit",
        'uri' => '#',
        'order' => '1',
        'icon' => 'fa-money'
    ));
    
    # Get Currency
    $getCurrency = Capsule::table('tblcurrencies')->where('id', $client->currency)->get();
    
    # Retrieve the panel we just created.
    $balancePanel = $primarySidebar->getChild('Client-Balance');
    
    // Move the panel to the end of the sorting order so it's always displayed
    // as the last panel in the sidebar.
    $balancePanel->moveToBack();
    $balancePanel->setOrder(0);
    
    # Add Balance.
    $balancePanel->addChild('balance-amount', array(
        'uri' => 'clientarea.php?action=addfunds',
        'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.$client->credit.' '. $getCurrency['0']->suffix.'</h4>',
        'order' => 1
    ));
    
    $balancePanel->setFooterHtml(
        '<a href="clientarea.php?action=addfunds" class="btn btn-success btn-sm btn-block">
            <i class="fa fa-plus"></i> Add Funds
        </a>'
    );

});

 

Screenshot_2021-04-23-15-47-28-258_com.android.chrome.jpg

Link to comment
Share on other sites

2 hours ago, Piyush Mahes said:

Hello i have an hook, i want to load/show that hook only on client area home page and on the top of Your Info box.

there are versions of that hook that only show on the client home page in the original thread....

do you have access to the login information hook ? I suspect that may be trying to set itself to be top too.

Link to comment
Share on other sites

2 minutes ago, brian! said:

there are versions of that hook that only show on the client home page in the original thread....

do you have access to the login information hook ? I suspect that may be trying to set itself to be top too.

No sir, this is a screenshot of another site they're having this feature that the Credit hook will show only in clientarea page.

I have that credit hook but i want that the hook only display in clientarea page , if user go to services page or billing page or any other page then the hook shouldn't load . Please tell me how can i do this

Link to comment
Share on other sites

15 minutes ago, brian! said:

Great it is done. Now any idea how to set login information hook? I want to add that login information option to clientarea. Which shows client status , last logged in date , last login IP and last login location and a button , you can check the screenshot i attached . and if you can't tell then atleast tell me how can i get last logged in IP and account status and how can i display it to client like shown in the screenshot

Screenshot_2021-04-23-19-06-05-240_com.android.chrome.jpg

Link to comment
Share on other sites

19 hours ago, Piyush Mahes said:

Which shows client status

why? a user doesn't need to know if they are marked as Active or Inactive - it makes absolutely no difference to what they can do when logged in.... in fact, depending on WHMCS settings, if they login and are Inactive today, they might login and be shown as Active tomorrow - the status is irrelevant.

19 hours ago, Piyush Mahes said:

last logged in date , last login IP and last login location

when the user logs in, it updates the database immediately... so if I login today, the date/time stored will be NOW, the IP address will be my current IP address NOW... and for the location, you would need to use a third-party Geo-IP solution to convert the IP to a location ) - but in reality, it's going to be the location where I am NOW (which I can check by looking out of a window - unless i'm using a VPN!)) 🌍

if you want to show the login details for the previous time they logged in, you can't because WHMCS doesn't store them.... you could write solutions to log this information to a separate database table upon each login and then reference that data in a sidebar hook - but that's more than just a sidebar hook.

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