Piyush Mahes Posted April 23, 2021 Share Posted April 23, 2021 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>' ); }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 23, 2021 Share Posted April 23, 2021 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. 0 Quote Link to comment Share on other sites More sharing options...
Piyush Mahes Posted April 23, 2021 Author Share Posted April 23, 2021 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 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 23, 2021 Share Posted April 23, 2021 I posted the link to the require code changes... https://whmcs.community/topic/247841-display-credit-balance-in-six-template/page/2/?tab=comments#comment-1172193 0 Quote Link to comment Share on other sites More sharing options...
Piyush Mahes Posted April 23, 2021 Author Share Posted April 23, 2021 15 minutes ago, brian! said: I posted the link to the require code changes... https://whmcs.community/topic/247841-display-credit-balance-in-six-template/page/2/?tab=comments#comment-1172193 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 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 24, 2021 Share Posted April 24, 2021 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. 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.