Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dparker1005/6698982014e4b41a6863e4d6168e0536 to your computer and use it in GitHub Desktop.
Save dparker1005/6698982014e4b41a6863e4d6168e0536 to your computer and use it in GitHub Desktop.
Adds content from Visits, Views, and Logins report to Member List to CSV export.
<?php
// Copy from below here...
/*
* Adds content from Visits, Views, and Logins report to Member List to CSV export.
*
* Here is where all the columns in the Visits, Views, and Logins report are filled
* in case you would like to customize this Gist:
* https://github.com/strangerstudios/paid-memberships-pro/blob/c3129bfce929bb4f5e7dd03f5efd74c209a5530e/adminpages/reports/login.php#L215-L252
*/
function my_pmpro_csv_export_add_views_column( $columns ) {
$columns['Total Views'] = "my_pmpro_csv_export_fill_views_column";
return $columns;
}
add_filter( 'pmpro_members_list_csv_extra_columns', 'my_pmpro_csv_export_add_views_column' );
function my_pmpro_csv_export_fill_views_column( $user, $heading ) {
$views = pmpro_reports_get_values_for_user("views", $user->ID);
// Can un-comment if you would like to use these values...
/*
$visits = pmpro_reports_get_values_for_user("visits", $user->ID);
$logins = pmpro_reports_get_values_for_user("logins", $user->ID);
if ( empty( $logins ) ) {
$logins = array("last"=>"N/A", "week"=>"N/A", "month"=>"N/A", "ytd"=>"N/A", "alltime"=>"N/A");
}
*/
return $views['alltime'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment