| @@ -166,22 +166,22 @@ | ||
| 166 | 166 | if ( is_wp_error( $subscriber ) ) { |
| 167 | 167 | wp_send_json_error( $subscriber->get_error_message() ); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - // Extract the subscriber's email. | |
| 171 | - $email = $subscriber['email_address']; | |
| 172 | - | |
| 173 | 170 | // Store the subscriber ID as a cookie. |
| 174 | 171 | $subscriber = new ConvertKit_Subscriber(); |
| 175 | 172 | $subscriber->set( $subscriber_id ); |
| 176 | 173 | |
| 177 | 174 | // Tag the subscriber with the Post's tag. |
| 178 | - $tag = $api->tag_subscribe( $tag_id, $email ); | |
| 175 | + $tag = $api->tag_subscribe( $tag_id, $subscriber['email_address'] ); | |
| 179 | 176 | |
| 180 | 177 | // Bail if an error occured tagging the subscriber. |
| 181 | 178 | if ( is_wp_error( $tag ) ) { |
| 182 | 179 | wp_send_json_error( $tag ); |
| 183 | 180 | } |
| 181 | + | |
| 182 | + // Store the subscriber ID as a cookie. | |
| 183 | + setcookie( 'ck_subscriber_id', $subscriber['id'], time() + ( 365 * DAY_IN_SECONDS ), '/' ); | |
| 184 | 184 | |
| 185 | 185 | wp_send_json_success( $tag ); |
| 186 | 186 | |
| 187 | 187 | } |