Created
July 31, 2020 08:24
-
-
Save andrewlimaza/351adf8c6e45c97b2cc11cd803405f6c to your computer and use it in GitHub Desktop.
Add Register Helper File Upload Field to Member's 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 | |
/** | |
* Add the full URL of a file upload field to member export CSV. | |
* Adjust the 'my_image' value with the relevant Register Helper field key. | |
* You can add this code snippet to your WordPress site following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
// Add a custom column to the CSV export. | |
function my_pmpro_members_list_csv_extra_columns ( $columns ) { | |
$columns["uploaded"] = "my_pmpro_members_list_uploaded"; | |
return $columns; | |
} | |
add_filter( 'pmpro_members_list_csv_extra_columns', 'my_pmpro_members_list_csv_extra_columns', 10 ); | |
// Callback to get the value. | |
function my_pmpro_members_list_uploaded ( $user ) { | |
$uploaded_value = get_user_meta( $user->ID, 'my_image', true ); // change 'my_image' to the file upload field meta key from Register Helper | |
if ( is_array( $uploaded_value ) ) { | |
$uploaded_value = $uploaded_value['fullurl']; | |
} | |
return $uploaded_value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment