pmpro_report_login_wp_login

The Paid Memberships Pro pmpro report login wp function.

Description

pmpro_report_login_wp_login( $user_login ); 

Parameters (1)

0. $user_login
The user login.

Usage

  1. if ( !function_exists( 'pmpro_report_login_wp_login' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/adminpages/reports/login.php'; 
  3.  
  4. // The user login. 
  5. $user_login = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_report_login_wp_login($user_login); 
  9.  

Defined (1)

The function is defined in the following location(s).

/adminpages/reports/login.php  
  1. function pmpro_report_login_wp_login($user_login) 
  2. $now = current_time('timestamp'); 
  3.  
  4. //get user data 
  5. $user = get_user_by("login", $user_login);  
  6. $logins = $user->pmpro_logins; 
  7. if(empty($logins)) 
  8. $logins = array("last"=>"N/A", "thisdate"=>NULL, "month"=>0, "thismonth"=> NULL, "alltime"=>0); 
  9.  
  10. //track logins for user 
  11. $logins['last'] = date_i18n(get_option("date_format"), $now); 
  12. $logins['alltime']++; 
  13. $thismonth = date_i18n("n", $now); 
  14. if($thismonth == $logins['thismonth']) 
  15. $logins['month']++; 
  16. else 
  17. {  
  18. $logins['month'] = 1; 
  19. $logins['thismonth'] = $thismonth; 
  20.  
  21. //update user data 
  22. update_user_meta($user->ID, "pmpro_logins", $logins); 
  23.  
  24. //track logins overall 
  25. $logins = get_option("pmpro_logins"); 
  26. if(empty($logins)) 
  27. $logins = array("today"=>0, "thisdate"=>NULL, "month"=>0, "thismonth"=>NULL, "alltime"=>0); 
  28.  
  29. $logins['alltime']++; 
  30. $thisdate = date_i18n("Y-d-m", $now); 
  31. if($thisdate == $logins['thisdate']) 
  32. $logins['today']++; 
  33. else 
  34. $logins['today'] = 1; 
  35. $logins['thisdate'] = $thisdate; 
  36. if($thismonth == $logins['thismonth']) 
  37. $logins['month']++; 
  38. else 
  39. $logins['month'] = 1; 
  40. $logins['thismonth'] = $thismonth; 
  41.  
  42. update_option("pmpro_logins", $logins);