Must Use-Plugin not running
-
Hi,
Im trying to get an email notification any time a subsite user uploads media via the wp media page. I have 40 sub-domains in a sub-domain based Multisite – when i run the plugin /function from the main domain functions.php file it runs fine so i know it works; but of course i need it to be detected from All subsites; not the main domain. The code is thus:function otz_new_attachment_email( $att_id ) { $blogid = get_current_blog_id(); // ensure we only operate on a subsite and not the main site (blog-id #1) if( !empty($blogid) && $blogid!=1 ) { $super_email = null; $usrdata = get_user_by('id', 1); if($usrdata != false) $super_email = $usrdata->user_email; if( empty($super_email) ) die("No super admin data found"); $headers = "From:$super_email\r\n"; $headers .= "Reply-To:$super_email\r\n"; $headers .= "X-Mailer: PHP/".phpversion()."\r\n"; $headers .= "content-type: text/html"; $subject = 'Media Upload Detected'; $body = '<p>New client media uploaded with an attachement ID of : '.$att_id.'.</p>'. wp_get_attachment_link( $att_id,'',true,false,'click here to view this attachment' ); @wp_mail( $super_email, $subject, $body, $headers ); } } add_action('add_attachment','otz_new_attachment_email', 10, 1);Could it be that my chosen hook (‘add_attachment’) cannot run inside a MU-Plugin or could it be any of the other standard wp functions? get_current_blog_id(), get_user_by() Or as i fear maybe because im trying to reference super-admin details from a subsite? i really don’t know??
Research shows hat the load order for WP is:
- the WordPress core code
- mu-plugins
- plugins
- functions.php
- the theme code for the specific template being displayed
I can run a test, simple Hello World script so know my MU-Plugins are capable of running on my installation – any ideas anyone
thanks
The topic ‘Must Use-Plugin not running’ is closed to new replies.