public function send_email($email_info = null) { if (is_null($email_info)) { $email_info = self::get_email_info($this->user_member_ids()); } // If there are actually people to send to, send them individual emails if (!empty($email_info)) { // We have to allow the current user to magically be a member of the plan so we can access all the plan data $this->allow_magic_member = true; $ref = $this->latest_reading(); if ($ref && $ref->is_valid()) { $ref_str = $ref->get_string(); $ref_url = bfox_ref_bible_url($ref_str); $subject = sprintf(__('[%s] #%d: %s', 'bfox'), $this->label(), $this->latest_reading_id() + 1, $ref->get_string(BibleMeta::name_short)); $msg_base = sprintf(__("Reading Schedule: %s\nToday's Reading: #%d %s\n\nStudy this passage: %s\nShare your thoughts: %s\nMark passage as read: %s\n\n---------------------\n", 'bfox'), $this->label(), $this->latest_reading_id() + 1, $ref_str, $ref_url, $ref_url . '#whats-new', $this->mark_read_url($this->latest_reading_id())); // Send an email to each user foreach ($email_info as $user) { $user_id = $user->ID; $message = $msg_base; $settings_link = bp_core_get_user_domain($user_id) . BP_SETTINGS_SLUG . '/notifications/'; $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link); wp_mail($user->user_email, $subject, $message); } } // Reset magic member $this->allow_magic_member = false; } return $this->update_next_email_time(); }
function bfox_bp_plans_reading_redirect(BfoxReadingSchedule $schedule, $reading_num, $action) { global $bp; // If there is a reading num specified if ($reading_num && $reading_num <= $schedule->reading_count) { $reading_id = $reading_num - 1; // If we are marking the reading as read if ('read' == $action) { BfoxReadingSchedule::add_progress(array($schedule->id => array($reading_id)), $bp->loggedin_user->id); bp_core_add_message(sprintf(__('Reading #%d marked as read.', 'bfox'), $reading_num)); bp_core_redirect($schedule->url()); } // Redirect to the Bible Reader $readings = $schedule->readings(); if (isset($readings[$reading_id]) && $readings[$reading_id]->is_valid()) { bp_core_redirect(bfox_ref_bible_url($readings[$reading_id]->get_string())); } bp_core_redirect($schedule->url()); } }