function psp_update_doc_fe() { $project_id = $_POST["project_id"]; $project_name = get_the_title($project_id); $doc_id = $_POST["doc_id"]; $status = $_POST["status"]; $filename = $_POST["filename"]; $editor = $_POST["editor"]; $users = $_POST["users"]; $message = "<h3 style='font-size: 18px; font-weight: normal; font-family: Arial, Helvetica, San-serif;'>" . $project_name . "</h3>"; $message .= "<p><strong>" . $filename . " status has been changed to " . $status . " by " . $editor . "</p>"; $message .= $_POST["message"]; $subject = $project_name . ": " . $filename . " status has been changed to " . $status . " by " . $editor; $docs = get_field('documents', $project_id); $docs[$doc_id]['status'] = $status; update_field('documents', $docs, $project_id); foreach ($users as $user) { psp_send_notification($user, $subject, $message, $project_id); } }
function psp_notify_users($post_id) { // Bail if we're doing an auto save if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // if our current user can't edit this post, bail if (!current_user_can('edit_post', $post_id)) { return; } if (get_post_type($post_id) == 'psp_projects') { // Check to see if notifications were turned on if (isset($_POST['psp-notify-users'])) { // Get an array of users $user_ids = $_POST['psp-user']; $progress = psp_compute_progress($post_id); $subject = $_POST['psp-notification-subject']; $message = $_POST['psp-notify-message']; foreach ($user_ids as $user_id) { psp_send_notification($user_id, $subject, $message, $post_id, $progress); } } } }