Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created July 31, 2020 08:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlimaza/351adf8c6e45c97b2cc11cd803405f6c to your computer and use it in GitHub Desktop.
Save andrewlimaza/351adf8c6e45c97b2cc11cd803405f6c to your computer and use it in GitHub Desktop.
Add Register Helper File Upload Field to Member's CSV Export
<?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