We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    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);


      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 10208 ☆ A M B ☆
      • 1,780 Posts
      Bump...

      Pay attention to The Amazing Bob people! :~}
        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster