Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Forked from mathetos/functions.php
Created June 28, 2016 18:13
Show Gist options
  • Save Shelob9/452c4d0f57033e3495fcbc012ff72129 to your computer and use it in GitHub Desktop.
Save Shelob9/452c4d0f57033e3495fcbc012ff72129 to your computer and use it in GitHub Desktop.
Custom Autopopulate Dropdown for CalderaForms
add_filter( 'caldera_forms_autopopulate_options_post_value_field', 'givewp_customer_addon_purchases', 24, 2 );
function givewp_customer_addon_purchases()
{
$current_user = wp_get_current_user();
$purchases = edd_get_users_purchases($current_user->user_email, 100, false, 'any');
if ( $purchases ) {
foreach ($purchases as $purchase) {
$licenses = edd_software_licensing()->get_licenses_of_purchase( $purchase->ID );
$addons = array();
if( $licenses ) {
foreach ( $licenses as $license ) {
$dname = edd_software_licensing()->get_download_name($license->ID);
$addons[] = $dname;
}
}
}
return $addons;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment