Created
May 5, 2020 16:01
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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