php - Editing a plugin - User Messaging WP -
a question newbie in php:
i have plugin called user messaging wpmu dev wordpress, allows users communicate each other. paid plugin. want, admin of wp receive content of every message being sent (for private , moderation reasons) got advice of i'm trying follow.
"unfortunately, there no hooks achieve want. therefore, need make modifications plugin. doesn't require coding, need function messaging_new_message_notification() in messaging.php file. function sends email notifications user when message sent. need duplicate call wp_mail() in line 398 pointing specific email address. should notice email sent when user notification settings enabled, might need duplicate whole block if want send custom email default."
so have code:
function messaging_new_message_notification($tmp_to_uid,$tmp_from_uid,$tmp_subject,$tmp_content) { global $wpdb, $current_site, $user_id, $messaging_email_notification_subject, $messaging_email_notification_content; if (is_multisite()) { $site_name = $current_site->site_name; $site_url = 'http://'. $current_site->domain; } else { $site_name = get_option('blogname'); $site_url = get_option('siteurl'); } if (get_user_meta($tmp_to_uid,'message_email_notification') != 'no'){ $tmp_to_username = $wpdb->get_var($wpdb->prepare("select user_login " . $wpdb->users . " id = %d", $tmp_to_uid)); $tmp_to_email = $wpdb->get_var($wpdb->prepare("select user_email " . $wpdb->users . " id = %s", $tmp_to_uid)); $tmp_from_username = $wpdb->get_var($wpdb->prepare("select user_login " . $wpdb->users . " id = %d", $tmp_from_uid)); $message_content = get_site_option('messaging_email_notification_content', $messaging_email_notification_content); $message_content = str_replace( "site_name", $site_name, $message_content ); $message_content = str_replace( "site_url", $site_url, $message_content ); $message_content = str_replace( "to_user", $tmp_to_username, $message_content ); $message_content = str_replace( "from_user", $tmp_from_username, $message_content ); $message_content = str_replace( "\'", "'", $message_content ); $subject_content = get_site_option('messaging_email_notification_subject', $messaging_email_notification_subject); $subject_content = str_replace( "site_name", $site_name, $subject_content ); $admin_email = get_site_option('admin_email'); if ($admin_email == ''){ $admin_email = 'admin@' . $current_site->domain; } $from_email = $admin_email; $message_headers = "mime-version: 1.0\n" . "from: " . $site_name . " <{$from_email}>\n" . "content-type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; wp_mail($tmp_to_email, $subject_content, $message_content, $message_headers);
i'm trying understand need , start.
instead of duplicating whole block, move if (get_user_meta($tmp_to_uid,'message_email_notification') != 'no')
encapsulate 1 of wp_mail()
functions , send email admin:
if (get_user_meta($tmp_to_uid,'message_email_notification') != 'no'){ wp_mail($tmp_to_email, $subject_content, $message_content, $message_headers); } wp_mail($admin_email, $subject_content, $message_content, $message_headers);
note you'll need perform modification each time update plugin.
Comments
Post a Comment