cafe_imported_object_id()
Purpose
Returns the post, term or user that was imported from a record of another system: the
"old ID → new ID" lookup that connects imported data. For example: the old
agent_id 7 of a property → the agent post a migration created from agent 7.
Syntax
cafe_imported_object_id( string $source, string|int $source_id, string $object_type = 'post' ): int
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$source |
string | - | The source key used when importing (CAFE → Migration: the migration's Source key; cafe_import_object(): its source). |
$source_id |
string|int | - | The record's ID in the old system. |
$object_type |
string | 'post' |
'post', 'term' or 'user'. |
Return value
The object ID, or 0 when nothing was imported from that record (or the post is in
the trash).
Example
$agent_post_id = cafe_imported_object_id( 'legacy-agents', $row->agent_id );
if ( $agent_post_id ) {
cafe_update_field( 'agent', $agent_post_id, $property_id );
}
Notes
- One indexed query. To resolve many IDs, prefer CAFE → Migration's Old ID → imported post, term or user transformation, which looks up a whole batch at once.
- Source IDs are never assumed to equal WordPress IDs.
- Since 0.13.0.