Forked from dparker1005/pmpro_csv_export_add_views_column.php
Last active
May 31, 2021 07:36
-
-
Save femiyb/2af3b088a7bb25c51f20a9fd9a6d46a8 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 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"; | |
$columns['Visits'] = "my_pmpro_csv_export_fill_visits_column"; | |
$columns['Logins'] = "my_pmpro_csv_export_fill_logins_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); | |
if ( empty( $logins ) ) { | |
$logins = array("last"=>"N/A", "week"=>"N/A", "month"=>"N/A", "ytd"=>"N/A", "alltime"=>"N/A"); | |
} | |
return $views['alltime']; | |
} | |
function my_pmpro_csv_export_fill_visits_column( $user, $heading ) { | |
$visits = pmpro_reports_get_values_for_user("visits", $user->ID); | |
return $visits['alltime']; | |
} | |
function my_pmpro_csv_export_fill_logins_column( $user, $heading ) { | |
$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 $logins['alltime']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment