Yes, yes you can
You will need to hook into the add_attachment
action, though there are others that may be more appropriate. Then you grab the list of administrators and send an email.
Here is a sample plugin I created for you:
<?php
/*
Plugin Name: Notify on Attachment Creation
Plugin URI: http://www.tomjn.com
Description: Send a notification when an attachment is created
Version: 1.03
Author: Tom J Nowell
Author URI: http://www.tomjn.com
*/
function new_attachment_email($att_id){
$recipients = array();
// who should it be sent to?
global $wpdb;
$key = $wpdb->prefix."user_level";
$admins = $wpdb->get_results($wpdb->prepare("SELECT user_id from $wpdb->usermeta AS um WHERE um.meta_key ='". $key."' AND um.meta_value = 10"));
if(!empty($admins)){
foreach($admins as $admin){
$userdata = get_userdata($admin->user_id);
$recipients[] = $userdata->user_email;
}
} else {
wp_die('nicht');
}
if(is_multisite()){
$superadmins = get_super_admins();
if(!empty($superadmins)){
foreach($superadmins as $superadmin){
$u = get_userdatabylogin($superadmin);
if($u != false){
if(!in_array($u->user_email,$recipients)){
$recipients[] = $u->user_email;
}
}
}
}
}
// send the email
if(empty($recipients)){
// there is nobody to send this to? Abort!
wp_die('oh dear god');
return;
}
$admin_email = get_option('admin_email');
$headers= "From:$admin_email\r\n";
$headers .= "Reply-To:$admin_email\r\n";
$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
$headers .= "content-type: text/html";
$subject="New Attachment upload";
$template="<p>new attachment uploaded to WordPress with the ID: ".$att_id.'.</p>'. wp_get_attachment_link( $att_id,'',true,false,'click here to view this attachment' );
foreach($recipients as $to){
@wp_mail($to, $subject, $template, $headers);
}
}
add_action('add_attachment','new_attachment_email',1,1);
This will send an email to the administrators and super admins of a wordpress site/network when a new attachment is created.