Jump to content

Want to show Last logged details


Recommended Posts

Hi

I want to show Last logged IP of clients and that login details will shown in whmcs client area like:

 

Last logged in on Aug 29, 2020, 11:02 AM (EST)

 

<?php

function ipxcoreaddIPToList($vars) {

	$userid = $vars['userid'];
    $ipaddress =  $_SERVER["HTTP_CF_CONNECTING_IP"];
	$desc = "Client area login from: " . gethostbyaddr($ipaddress);
	$user = "Client";
	$nowTS = date("Y-m-d H:i:s");

	$dataadd = array("date" => $nowTS, "userid"=>$userid, "ipaddr"=>$ipaddress, "description"=>$desc, "user"=>$user);
	insert_query("tblactivitylog", $dataadd);

}

add_hook('ClientLogin', 1, 'ipxcoreaddIPToList');

?>

I have the above code but it show in the Client log details. I want to show that in the whmcs client area so that client can know from which ip along with date and time they have last login to the whmcs client area.

 
Link to comment
Share on other sites

1 hour ago, Deepu3110 said:

I have the above code but it show in the Client log details.

by definition, tha thook is just logging the current login details to the activity log.

https://github.com/damianharouff/whmcshook-recordlogin/blob/master/ipxcore-addUserIPtoTable.php

Quote

Place this file into your WHMCS dir /includes/hooks/ and it will then record all client area logins to the client's activity log. Please keep in mind that it will record "Login as Client" logins from the admin interface, too.

1 hour ago, Deepu3110 said:

I want to show that in the whmcs client area so that client can know from which ip along with date and time they have last login to the whmcs client area.

you mean not the current login, but the one before that ? (if it's the current login, that's easy).

three thoughts...

  1. if your above hook that logs the IP details is working, then to show those details in the client area would require another hook to pull that information from the tblactivitylog table... though i'd be inclined to use a separate table to store those details as it should make the retrieval coding simpler.
  2. I think ClientLogin hook point gets deprecated in v8 and replaced with UserLogin - so the above hook as written might not work immediately in v8.
  3. the thread below might be useful where Dennis expands on the complication of v8 users potentially having multiple accounts...... it's a pity he posted that in developer corner... if it had been the v8 beta forums, someone from WHMCS might have seen it.

I think to do what you want in v7, e.g log and retrieve login details, would be simple enough - these days you wouldn't really need server variables and you should be able to do everything with the model classes... however. from what Dennis is saying, it might not be so straightforward in v8 - though that depends on the v8 technical docs and they might not be released until after v8 goes GA... and I wouldn't waste time trying to figure out whether it would work in v8 until it goes GA.

36 minutes ago, VirtualWorldGlobal said:

Any specific reasons for showing that to a client ?

I assume so that the user can see whether the last login was them... so might be useful to show only if the current login IP is different from the previous one.... and anyway, there's no guarantee that the user even knows their own IP address!

Link to comment
Share on other sites

3 minutes ago, brian! said:

I assume so that the user can see whether the last login was them... so might be useful to show only if the current login IP is different from the previous one.... and anyway, there's no guarantee that the user even knows their own IP address!

Yes actually if only the user knows / remembers his last login IP or only if they use a Static IP, cPanel shows last login but I haven't seen many who actually check the login...

Link to comment
Share on other sites

32 minutes ago, VirtualWorldGlobal said:

Yes actually if only the user knows / remembers his last login IP or only if they use a Static IP, cPanel shows last login but I haven't seen many who actually check the login...

Can we just show like this Last logged in on Aug 29, 2020, 11:02 AM (EST) only date and time in client area.

Link to comment
Share on other sites

  • 2 years later...

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