Skip to content

Instantly share code, notes, and snippets.

@juanlistab
juanlistab / programmatically-update-unique-key.md
Created April 19, 2023 03:28 — forked from trey8611/programmatically-update-unique-key.md
[Programmatically update unique identifier] #wpallimport

Before using this snippet, it is really important to back-up your database so that you can roll back if needed. Also:

  • Note the $import_id checks in each function - you need to change '5' to the import ID that you want to target.
  • Note 'id' and {id[1]} in the functions. Change these to the element you want to become the new Unique Identifier.
add_action( 'pmxi_saved_post', 'my_update_uid', 10, 3 );
add_action( 'pmxi_after_xml_import', 'my_update_import_uid', 10, 2 );

function my_update_uid( $post_id, $xml_data, $is_update ) {