I can't figure out why this won't work. When a new document is created, I want to duplicate it and send the user to the Create/Edit page for the duplicate.
Both resources (the new one and its duplicate) are created and if I paste the URL I get in the debug output into the browser's address bar, it takes me right where I want to go, but the plugin crashes with an endless save bar when it hits the redirect.
$pt = $resource->get('pagetitle') . '-draft';
$params = array(
'newName' => $pt,
'publishMode' => 'unpublish',
'parent' => $draftFolder,
);
$newResource = $resource->duplicate($params);
$draftId = $newResource->get('id');
$newResource->set('published', '0');
$newResource->setTVValue('Approved', 'No');
$newResource->save();
$resource->set('published', '0');
$resource->save();
$modx->reloadContext();
$url = MODX_URL_SCHEME . MODX_HTTP_HOST . MODX_BASE_URL . 'manager/index.php?&a=30&id=' . $draftId;
my_debug('URL: ' . $url);
$modx->sendRedirect($url);