pmpro_report_login_wp_views

The Paid Memberships Pro pmpro report login wp views function.

Description

pmpro_report_login_wp_views(); 

Usage

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

Defined (1)

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

/adminpages/reports/login.php  
  1. function pmpro_report_login_wp_views() 
  2. //don't track admin 
  3. if(is_admin()) 
  4. return; 
  5.  
  6. global $current_user; 
  7. $now = current_time('timestamp'); 
  8.  
  9. //track for user 
  10. if(!empty($current_user->ID)) 
  11. {  
  12. $views = $current_user->pmpro_views;  
  13. if(empty($views)) 
  14. $views = array("last"=>"N/A", "month"=>0, "alltime"=>0); 
  15.  
  16. //track logins for user 
  17. $views['last'] = date_i18n(get_option("date_format"), $now); 
  18. $views['alltime']++; 
  19. $thismonth = date_i18n("n", $now); 
  20. if(isset($views['thismonth']) && $thismonth == $views['thismonth']) 
  21. $views['month']++; 
  22. else 
  23. $views['month'] = 1; 
  24. $views['thismonth'] = $thismonth; 
  25.  
  26. //update user data 
  27. update_user_meta($current_user->ID, "pmpro_views", $views); 
  28.  
  29. //track for all 
  30. $views = get_option("pmpro_views");  
  31. if(empty($views)) 
  32. $views = array("today"=>0, "thisdate"=> NULL, "month"=>0, "thismonth"=> NULL, "alltime"=>0); 
  33.  
  34. $views['alltime']++; 
  35. $thisdate = date_i18n("Y-d-m", $now); 
  36. if($thisdate == $views['thisdate']) 
  37. $views['today']++; 
  38. else 
  39. $views['today'] = 1; 
  40. $views['thisdate'] = $thisdate; 
  41. $thismonth = date_i18n("n", $now); 
  42. if(isset($views['thismonth']) && $thismonth == $views['thismonth']) 
  43. $views['month']++; 
  44. else 
  45. $views['month'] = 1; 
  46. $views['thismonth'] = $thismonth; 
  47.  
  48. update_option("pmpro_views", $views);