This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

Ajit Sahane

  • ****
  • 147 posts
  • https://bestclassifiedsusa.com
Osclass Admin Panel Login Notification Alert Email
« on: January 17, 2020, 07:53:10 AM »
Hello how to get osclass admin login & logout alert email?   My xyz.com website and i have sub-admin also, now i am share sub-admin logins to my team or staff member, here i want to know when they login or logout.

wordpress same functionality available. So, i think here also same thing can possible. I am not a coder so i can't but this is very important thing.

Anyone can have solution or any plugin available ?

1) Main Admin login or logout both email notification alert want to desire email id. 
2) Newly created Sub admin also same email alert want to desire email id.     

Osclass team kindly develop any plugin or pls share any custom code with implement guide.

I am ready to pay for this task if any expert can do that.

*

MB Themes

Re: Osclass Admin Panel Login Notification Alert Email
« Reply #1 on: January 17, 2020, 04:56:37 PM »
I do not think this is doable as osclass does not have hooks for such actions so you cannot add emails there.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Ajit Sahane

  • ****
  • 147 posts
  • https://bestclassifiedsusa.com
Re: Osclass Admin Panel Login Notification Alert Email
« Reply #2 on: March 06, 2020, 07:31:01 AM »
 Finally, I got oc-admin login alert email notification by direct custom php code adding to login.php

 Yes, admin hook not work only direct method you can get this.

 Thanks to my private osclass developer.

 If anyone want you can contact me and off course its Paid Task.

 PM for more details.


Marked as best answer by frosticek on March 07, 2020, 02:12:15 PM
*

MB Themes

Re: Osclass Admin Panel Login Notification Alert Email
« Reply #3 on: March 06, 2020, 08:27:28 AM »
@Ajit
I've been checking for that hook and found it in login.php, so code should be very simple.
Placing above code to index.php of any installed plugin will work, at least for me:

Code: [Select]
// NOTIFY SITE OWNER ABOUT ADMIN LOGIN TO OSCLASS
function notify_admin_has_logged($admin) {
  $text = sprintf('There was new login to oc-admin area of your site, admin logged in: %s (%s) at %s from ip %s', $admin['s_name'], $admin['s_email'], date('Y-m-d H:i:s'), ($_SERVER['HTTP_CLIENT_IP'] ? : ($_SERVER['HTTP_X_FORWARDED_FOR'] ? : $_SERVER['REMOTE_ADDR'])));

  if($admin['s_username'] <> 'admin5') {   // word 'admin5' can be changed to any name you want to not receive notifications
    mail(osc_contact_email() , 'New admin login', $text);
  }
}

osc_add_hook('login_admin', 'notify_admin_has_logged', 9);

Outcome is getting raw email to site owner about admin login in form:
"There was new login to oc-admin area of your site, admin logged in: demo ([email protected]) at 2020-03-06 08:22:11 from ip 192.168.1.1"
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Ajit Sahane

  • ****
  • 147 posts
  • https://bestclassifiedsusa.com
Re: Osclass Admin Panel Login Notification Alert Email
« Reply #4 on: March 07, 2020, 06:56:44 AM »
Yes, this is also the best solution but now my direct code working fine with the fancy mailer.

look like - check attached jpg

*

MB Themes

Re: Osclass Admin Panel Login Notification Alert Email
« Reply #5 on: March 07, 2020, 12:22:18 PM »
Good  ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

officela

  • ***
  • 64 posts
Re: Osclass Admin Panel Login Notification Alert Email
« Reply #6 on: March 07, 2020, 01:35:07 PM »
Does not seems to work.

@Ajit
I've been checking for that hook and found it in login.php, so code should be very simple.
Placing above code to index.php of any installed plugin will work, at least for me:

Code: [Select]
// NOTIFY SITE OWNER ABOUT ADMIN LOGIN TO OSCLASS
function notify_admin_has_logged($admin) {
  $text = sprintf('There was new login to oc-admin area of your site, admin logged in: %s (%s) at %s from ip %s', $admin['s_name'], $admin['s_email'], date('Y-m-d H:i:s'), ($_SERVER['HTTP_CLIENT_IP'] ? : ($_SERVER['HTTP_X_FORWARDED_FOR'] ? : $_SERVER['REMOTE_ADDR'])));

  if($admin['s_username'] <> 'admin5') {   // word 'admin5' can be changed to any name you want to not receive notifications
    mail(osc_contact_email() , 'New admin login', $text);
  }
}

osc_add_hook('login_admin', 'notify_admin_has_logged', 9);

Outcome is getting raw email to site owner about admin login in form:
"There was new login to oc-admin area of your site, admin logged in: demo ([email protected]) at 2020-03-06 08:22:11 from ip 192.168.1.1"

You put the code you provided in any active plugin correct?

Or need also put this in login.php  - (osc_add_hook('login_admin', 'notify_admin_has_logged', 9);)
i've tried both ways and nothing.

*

MB Themes

Re: Osclass Admin Panel Login Notification Alert Email
« Reply #7 on: March 07, 2020, 02:12:02 PM »
Must be in index.php of any active plugin.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

officela

  • ***
  • 64 posts
Re: Osclass Admin Panel Login Notification Alert Email
« Reply #8 on: March 07, 2020, 06:25:49 PM »
yes, i read that above. i included your code inside the index.php of 3 active plugins ( 1 every time on my tests ) but not working.

*

MB Themes

Re: Osclass Admin Panel Login Notification Alert Email
« Reply #9 on: March 07, 2020, 08:27:20 PM »
Tested on 2 different installation and works flawlesly, so case closed for me
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots