Last active
August 29, 2015 14:09
-
-
Save bhwebworks/e3e76f5a35ac71cabbad to your computer and use it in GitHub Desktop.
Add headers to LearnDash ProPanel dashboard messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static function send_dashboard_emails($course_progress_data = null) { | |
if(empty($_POST["submit_propanel_email"]) || empty($_POST["course_id"]) || empty($_POST[ "learndash_propanel_message"]) || empty($_POST[ "learndash_propanel_subject"]) ) | |
return; | |
$course_id = $_POST["course_id"]; | |
if(is_null($course_progress_data)) | |
$course_progress_data = SFWD_LMS::course_progress_data($course_id); | |
if(empty($course_progress_data)) | |
return; | |
$course_id = $_POST["course_id"]; | |
if(empty($course_progress_data)) | |
return; | |
$users = $course_progress_data; | |
$email_to = array(); | |
// Check if the "from" input field is filled out | |
$message = stripslashes($_POST[ "learndash_propanel_message"]); | |
$subject = stripslashes($_POST[ "learndash_propanel_subject"]); | |
// BHWW - Get the website URL, remove the protocol, create the email headers | |
$url = get_bloginfo( 'url' ); | |
$regex = '#^https?://#'; | |
$url = preg_replace( $regex, '', $url ); | |
$headers = 'From: ' . get_bloginfo( 'name' ) . ' <no-reply@' . $url . '>'; | |
// message lines should not exceed 70 characters (PHP rule), so wrap it | |
$message = wordwrap($message, 70); | |
// send mail | |
foreach ($users as $user) { | |
//$email_to[] = $user['email']; | |
wp_mail($user['email'],$subject,$message,$headers); // BHWW - added $headers | |
} | |
return __("Message Sent", "ld_propanel"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment