Importers - tests save post_author in legacy

This commit is contained in:
eduardohumberto 2018-08-02 23:32:57 -03:00
parent fbd8d8b3a1
commit 1e6a57c700
1 changed files with 8 additions and 5 deletions

View File

@ -113,8 +113,6 @@ abstract class Importer {
private $error_log = []; private $error_log = [];
private $author = 0;
/** /**
* Wether to abort importer execution. * Wether to abort importer execution.
* @var bool * @var bool
@ -144,7 +142,11 @@ abstract class Importer {
} }
$this->id = uniqid(); $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; $_SESSION['tainacan_importer'][$this->get_id()] = $this;
@ -870,8 +872,9 @@ abstract class Importer {
$method_name = $steps[$current_step]['callback']; $method_name = $steps[$current_step]['callback'];
if (method_exists($this, $method_name)) { if (method_exists($this, $method_name)) {
$this->add_log('User in process: ' . $this->author); $author = $this->get_transient('author');
wp_set_current_user($this->author); $this->add_log('User in process: ' . $author);
wp_set_current_user($author);
$result = $this->$method_name(); $result = $this->$method_name();
} else { } else {
$this->add_error_log( 'Callback not found for step ' . $steps[$current_step]['name']); $this->add_error_log( 'Callback not found for step ' . $steps[$current_step]['name']);