| @@ -253,17 +253,42 @@ | ||
| 253 | 253 | 'output_content' |
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | 256 | // Get the subscriber's tags, to see if they subscribed to this tag. |
| 257 | - $tags = $api->get_subscriber_tags( $subscriber_id ); | |
| 257 | + if ( is_numeric( $subscriber_id ) ) { | |
| 258 | + $tags = $api->get_subscriber_tags( $subscriber_id ); | |
| 258 | 259 | |
| 259 | - // Bail if an error occurred. | |
| 260 | - if ( is_wp_error( $tags ) ) { | |
| 261 | - if ( $settings->debug_enabled() ) { | |
| 262 | - return '<!-- Kit Custom Content: ' . $tags->get_error_message() . ' -->'; | |
| 260 | + // Bail if an error occurred. | |
| 261 | + if ( is_wp_error( $tags ) ) { | |
| 262 | + if ( $settings->debug_enabled() ) { | |
| 263 | + return '<!-- Kit Custom Content: ' . $tags->get_error_message() . ' -->'; | |
| 264 | + } | |
| 265 | + | |
| 266 | + return ''; | |
| 263 | 267 | } |
| 268 | + } else { | |
| 269 | + // Subscriber ID is a signed subscriber ID. | |
| 270 | + // Get tags that the subscriber has access to via the profile() method. | |
| 271 | + $result = $api->profile( $subscriber_id ); | |
| 264 | 272 | |
| 265 | - return ''; | |
| 273 | + // If an error occurred, the subscriber ID is invalid. | |
| 274 | + if ( is_wp_error( $result ) ) { | |
| 275 | + if ( $settings->debug_enabled() ) { | |
| 276 | + return '<!-- Kit Custom Content: ' . $result->get_error_message() . ' -->'; | |
| 277 | + } | |
| 278 | + | |
| 279 | + return ''; | |
| 280 | + } | |
| 281 | + | |
| 282 | + // Build tags array. | |
| 283 | + $tags = array( | |
| 284 | + 'tags' => array(), | |
| 285 | + ); | |
| 286 | + foreach ( $result['tags'] as $tag_id ) { | |
| 287 | + $tags['tags'][] = array( | |
| 288 | + 'id' => $tag_id, | |
| 289 | + ); | |
| 290 | + } | |
| 266 | 291 | } |
| 267 | 292 | |
| 268 | 293 | // Bail if the subscriber has no tags. |
| 269 | 294 | if ( ! count( $tags ) ) { |