Fixed quiztech_ajax_send_job_invite on Manage Jobs page

This commit is contained in:
Ruben Ramirez 2025-04-03 21:34:50 -05:00
parent bce4ea4b62
commit d6a429fbdb

View file

@ -143,8 +143,16 @@ function quiztech_ajax_send_job_invite() {
// Generic failure from create_invitation if no WP_Error
wp_send_json_error( [ 'message' => esc_html__( 'Failed to create invitation.', 'quiztech' ) ], 500 );
} else {
// Success! $result might contain the token or true
wp_send_json_success( [ 'message' => esc_html__( 'Invitation sent successfully.', 'quiztech' ) ] );
// Success! $result contains the token. Now send the email.
$token = $result;
$email_sent = $invitations->send_invitation_email( $applicant_email, $token, [ 'job_title' => get_the_title( $job_id ) ] );
if ( $email_sent ) {
wp_send_json_success( [ 'message' => esc_html__( 'Invitation sent successfully.', 'quiztech' ) ] );
} else {
// Invitation created, but email failed.
wp_send_json_error( [ 'message' => esc_html__( 'Invitation created, but the email could not be sent. Please check email settings.', 'quiztech' ) ], 500 );
}
}
} catch ( \Exception $e ) {
// Catch any unexpected exceptions