Last active
August 29, 2015 13:56
-
-
Save amdrew/9178690 to your computer and use it in GitHub Desktop.
Easy Digital Downloads - add a new email tag called {vendor_emails}. This will output each download and the email address of who added it.
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 | |
/** | |
* Example | |
* For more information about your order, please contact one of the following vendors: | |
* {vendor_emails} | |
* / | |
/** | |
* Add a {vendor_emails} tag | |
*/ | |
function sumobi_edd_email_tags( $email_tags ) { | |
$email_tags[] = array( | |
'tag' => 'vendor_emails', | |
'description' => 'List each download purchased with the email address of the Shop vendor who added it', | |
'function' => 'sumobi_edd_vendor_emails' | |
); | |
return $email_tags; | |
} | |
add_filter( 'edd_email_tags', 'sumobi_edd_email_tags' ); | |
/** | |
* List each download with the email of the author (Shop Vendor who added it) | |
*/ | |
function sumobi_edd_vendor_emails() { | |
ob_start(); | |
$downloads = edd_get_purchase_session(); | |
$downloads = $downloads['downloads']; | |
if ( $downloads ) { | |
foreach ( $downloads as $key => $download ) { | |
$post = get_post( $download['id'] ); | |
$author_id = $post->post_author; | |
// download title | |
echo get_the_title( $download['id'] ) . '<br/>'; | |
// the email address of the author who added the download | |
echo get_the_author_meta( 'user_email', $author_id ) . '<br/><br/>'; | |
} | |
} | |
$html = ob_get_clean(); | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment