From 1e6a57c70002d2367a712a3d302d978f16b68ad7 Mon Sep 17 00:00:00 2001 From: eduardohumberto Date: Thu, 2 Aug 2018 23:32:57 -0300 Subject: [PATCH] Importers - tests save post_author in legacy --- src/importer/class-tainacan-importer.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/importer/class-tainacan-importer.php b/src/importer/class-tainacan-importer.php index 2fc3d3627..815717ca6 100644 --- a/src/importer/class-tainacan-importer.php +++ b/src/importer/class-tainacan-importer.php @@ -112,8 +112,6 @@ abstract class Importer { private $log = []; private $error_log = []; - - private $author = 0; /** * Wether to abort importer execution. @@ -144,7 +142,11 @@ abstract class Importer { } $this->id = uniqid(); - $this->author = get_current_user_id(); + + $author = get_current_user_id(); + if($author){ + $this->add_transient('author', $author); + } $_SESSION['tainacan_importer'][$this->get_id()] = $this; @@ -870,8 +872,9 @@ abstract class Importer { $method_name = $steps[$current_step]['callback']; if (method_exists($this, $method_name)) { - $this->add_log('User in process: ' . $this->author); - wp_set_current_user($this->author); + $author = $this->get_transient('author'); + $this->add_log('User in process: ' . $author); + wp_set_current_user($author); $result = $this->$method_name(); } else { $this->add_error_log( 'Callback not found for step ' . $steps[$current_step]['name']);