Fix: Use correct token value for invitation email link
This commit is contained in:
parent
b4638daa93
commit
a3f1bcb0ef
1 changed files with 11 additions and 6 deletions
|
|
@ -205,13 +205,18 @@ function quiztech_ajax_send_job_invite() {
|
|||
} elseif ( $result === false ) {
|
||||
// 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 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 ) ] );
|
||||
} elseif ( !is_array($result) || !isset($result['token']) ) {
|
||||
// Handle case where array isn't returned or token is missing
|
||||
\error_log('Quiztech Send Invite Error: create_invitation did not return expected array with token.');
|
||||
wp_send_json_error( [ 'message' => esc_html__( 'Failed to retrieve invitation token after creation.', 'quiztech' ) ], 500 );
|
||||
} else {
|
||||
// Success! $result contains the array. Extract the token.
|
||||
$token = $result['token'];
|
||||
// $invitation_id = $result['id']; // ID is available if needed later
|
||||
$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' ) ] );
|
||||
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 );
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue