Parcourir la source

#1075 When "Automatic profile creation from account name" is enabled and there are other mandatory fields, then error occured

Alex Trofimov il y a 8 ans
Parent
commit
f4c10a72bb
1 fichiers modifiés avec 14 ajouts et 11 suppressions
  1. 14 11
      template/scripts/BxBaseAccountForms.php

+ 14 - 11
template/scripts/BxBaseAccountForms.php

@@ -104,19 +104,22 @@ class BxBaseAccountForms extends BxDolProfileForms
             )));
             
             $a = BxDolService::call($sProfileModule, 'entity_add', array($iProfileId, $aProfileInfo));
-            if (0 != $a['code'])
-                return MsgBox(_t($a['message']));
 
-            BxDolService::call($sProfileModule, 'redirect_after_add', array($a['content']));
-        }
-        else {
-            $sRedirectUrl = !empty($sProfileModule) ? BxDolService::call($sProfileModule, 'profile_create_url', array(false)) : '';
-        
-            $this->_redirectAndExit(!empty($sRedirectUrl) ? $sRedirectUrl : getParam('sys_redirect_after_account_added'), true, array(
-                'account_id' => $iAccountId,
-                'profile_id' => $iProfileId,
-            ));
+            // in case of successful profile add redirect to the page after profile creation
+            if (0 == $a['code']) { 
+                BxDolService::call($sProfileModule, 'redirect_after_add', array($a['content']));
+                return;
+            }
+            // if creation failed, redirect to create profile form
         }
+
+        $sRedirectUrl = !empty($sProfileModule) ? BxDolService::call($sProfileModule, 'profile_create_url', array(false)) : '';
+    
+        $this->_redirectAndExit(!empty($sRedirectUrl) ? $sRedirectUrl : getParam('sys_redirect_after_account_added'), true, array(
+            'account_id' => $iAccountId,
+            'profile_id' => $iProfileId,
+        ));
+
     }
 
     public function onAccountCreated ($iAccountId, $isSetPendingApproval, $iAction = BX_PROFILE_ACTION_MANUAL)