Ver Fonte

#659 Redirect after profile creatin

Alex Trofimov há 9 anos atrás
pai
commit
f198db0211

+ 11 - 0
modules/base/profile/classes/BxBaseModProfileFormsEntryHelper.php

@@ -143,6 +143,17 @@ class BxBaseModProfileFormsEntryHelper extends BxBaseModGeneralFormsEntryHelper
         return '';
     }
 
+    protected function redirectAfterAdd($aContentInfo)
+    {
+        // if user just joined the redirect to the page where user comes from. 
+        // TODO: add an options to profile based modules: redirect to created profile, redirect to the last page, custom redirect
+        if ($sJoinReferrer = BxDolSession::getInstance()->getValue('join-referrer')) {
+            BxDolSession::getInstance()->unsetValue('join-referrer');
+            header('Location: ' . $sJoinReferrer);
+            exit;
+        }
+        parent::redirectAfterAdd($aContentInfo);
+    }
 }
 
 /** @} */

+ 15 - 1
template/scripts/BxBaseServiceAccount.php

@@ -28,7 +28,21 @@ class BxBaseServiceAccount extends BxDol
 	    $sLoginText = '';
         if (!isset($aParams['no_login_text']) || (int)$aParams['no_login_text'] == 1)
             $sLoginText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div>' . _t('_sys_txt_join_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=login')) . '</div>';
-
+        
+        if (isset($_SERVER['HTTP_REFERER']) && 0 === mb_stripos($_SERVER['HTTP_REFERER'], BX_DOL_URL_ROOT)) { // remember referrer
+            
+            $sJoinReferrer = $_SERVER['HTTP_REFERER'];
+            $aNoRelocatePages = array('forgot-password', 'login', 'create-account', 'logout');
+            foreach ($aNoRelocatePages as $s) {
+                if (false !== mb_stripos($sJoinReferrer, $s)) {
+                    $sJoinReferrer = '';
+                    break;
+                }
+            }   
+            if ($sJoinReferrer)
+                BxDolSession::getInstance()->setValue('join-referrer', $sJoinReferrer);
+        }
+        
         $sAuth = BxDolService::call('system', 'MemberAuthCode', array(), 'TemplServiceLogin');
 
         return $sAuth . $this->_oAccountForms->createAccountForm($aParams) . $sLoginText;