Redirect user to published article created in frontend
authorMatthias Schmidt <gravatronics@live.com>
Thu, 6 Jun 2019 17:09:05 +0000 (19:09 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 6 Jun 2019 17:09:05 +0000 (19:09 +0200)
See #2681

wcfsetup/install/files/lib/form/ArticleAddForm.class.php

index 3475aebd871a2246742cd177d6222c0cfdb9c7ca..96a3480587b4389179c5a5ab67c2045fc8eced1f 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 namespace wcf\form;
+use wcf\data\article\Article;
 use wcf\system\WCF;
+use wcf\util\HeaderUtil;
 
 /**
  * Shows the article add form.
@@ -20,4 +22,18 @@ class ArticleAddForm extends \wcf\acp\form\ArticleAddForm {
                
                WCF::getTPL()->assign(['articleIsFrontend' => true]);
        }
+       
+       /**
+        * @inheritDoc
+        */
+       public function save() {
+               parent::save();
+               
+               /** @var Article $article */
+               $article = $this->objectAction->getReturnValues()['returnValues'];
+               if ($article->publicationStatus == Article::PUBLISHED) {
+                       HeaderUtil::redirect($article->getLink());
+                       exit;
+               }
+       }
 }