Created
July 31, 2018 16:56
-
-
Save robertuniqid/f64521b21ad4d0b300e8cdcd020f9fc3 to your computer and use it in GitHub Desktop.
Send an Email Notification when an Assessment has a Status Change.
This file contains hidden or 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
<?php | |
add_action( 'wpep_user_set_assessment_data', function( $key, $value, $post_id, $question_id, $question_answer_id, $user_id ) { | |
if( $key != WPEP_USER_ASSESSMENT_STATUS ) | |
return; | |
$student_name = wpep_content_user_profile_format_name( $user_id ); | |
$status_label = wpep_get_setting_translated( 'assessment-status-label-' . $value ); | |
$admin_url = wpep_admin_url_statistics( [ | |
'tab' => 'assessments', | |
'assessment_id' => $post_id, | |
'user_id' => $user_id | |
] ); | |
/** Start : Where you configure the email, I suggest just setting your email address **/ | |
$email_address = 'your-email-here-goes-here'; | |
$email_title = "Assessment Status Changed to : $status_label for $student_name"; | |
$email_content = "Assessment Status Changed to : $status_label for $student_name <br/> | |
to view this submission go to <a href='$admin_url'>$admin_url</a>"; | |
/** End : Where you configure the email, I suggest just setting your email address **/ | |
wpep_controller()->email->send( | |
$email_address, | |
$email_title, | |
$email_content | |
); | |
}, 10, 6 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment