Skip to content

Instantly share code, notes, and snippets.

@InpsydeNiklas
Last active July 22, 2022 19:05
Show Gist options
  • Save InpsydeNiklas/e8e22e093cd8aec79d6e7284e6a7acc5 to your computer and use it in GitHub Desktop.
Save InpsydeNiklas/e8e22e093cd8aec79d6e7284e6a7acc5 to your computer and use it in GitHub Desktop.
MultilingualPress copy post meta GTIN field from Product Feed PRO ELITE
<?php
add_action('multilingualpress.metabox_after_relate_posts', function($context, $request) {
// get post meta value from source site
$ProductFeedELITEGtinValue = (string)$request->bodyValue(
'_woosea_gtin',
INPUT_POST,
FILTER_SANITIZE_STRING
);
// switch to remote sites and save post meta
$remoteSiteId = $context->remoteSiteId();
$remotePostId = $context->remotePostId();
switch_to_blog($remoteSiteId);
update_post_meta($remotePostId, '_woosea_gtin', $ProductFeedELITEGtinValue);
restore_current_blog();
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment