Fixed quiztech_ajax_send_job_invite on Manage Jobs page
This commit is contained in:
parent
bce4ea4b62
commit
d6a429fbdb
1 changed files with 10 additions and 2 deletions
|
|
@ -143,8 +143,16 @@ function quiztech_ajax_send_job_invite() {
|
||||||
// Generic failure from create_invitation if no WP_Error
|
// Generic failure from create_invitation if no WP_Error
|
||||||
wp_send_json_error( [ 'message' => esc_html__( 'Failed to create invitation.', 'quiztech' ) ], 500 );
|
wp_send_json_error( [ 'message' => esc_html__( 'Failed to create invitation.', 'quiztech' ) ], 500 );
|
||||||
} else {
|
} else {
|
||||||
// Success! $result might contain the token or true
|
// Success! $result contains the token. Now send the email.
|
||||||
wp_send_json_success( [ 'message' => esc_html__( 'Invitation sent successfully.', 'quiztech' ) ] );
|
$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 ( \Exception $e ) {
|
||||||
// Catch any unexpected exceptions
|
// Catch any unexpected exceptions
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue