Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add headers to LearnDash ProPanel dashboard messages
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