public static function onCustomEditor( $article, $user ) { global $wgRequest, $wgOut; $action = $wgRequest->getVal( 'action' ); $oldid = $wgRequest->getVal( 'oldid' ); $returnto = $wgRequest->getVal( 'wpReturnTo' ); $talkhere = $wgRequest->getVal( 'wpTalkHere' ); if (!$talkhere || $action != 'submit' || !$returnto || $oldid) return true; //go on as normal $to = Title::newFromText($returnto); if (!$to) return true; //go on as normal //use a wrapper to override redirection target $editor = new TalkHereEditPage( $article ); $editor->setReturnTo( $to ); $editor->edit(); $code = $editor->getCode(); if ( $code == EditPage::AS_SUCCESS_NEW_ARTICLE ) { $wgOut->redirect( $to->getFullURL() . '#talkhere' ); } elseif ( $code == EditPage::AS_SUCCESS_UPDATE ) { $wgOut->redirect( $to->getFullURL() . $editor->getAnchor() ); } return false; }