我有TYPO3 7.6.18版本。TYPO3如何設置fe_user的用戶組?
我正在定製登記和我在控制器中添加用戶在我的代碼:
$this->userRepository->add($user);
我需要設置用戶組
我想:
$user->setUsergroup(1);
但它調用的錯誤:
PHP Catchable Fatal Error: Argument 1 passed to TYPO3\CMS\Extbase\Domain\Model\FrontendUser::setUsergroup() must be an instance of TYPO3\CMS\Extbase\Persistence\ObjectStorage, integer given, called in /home/abenteuer/public_html/typo3conf/ext/feusersplus/Classes/Controller/NewController.php on line 68 and defined in /home/abenteuer/public_html/typo3/sysext/extbase/Classes/Domain/Model/FrontendUser.php line 192
我知道我應該將參數傳遞給setUsergroup(),它必須是TYPO3 \ CMS \ Extbase \ Persistence \ ObjectStorage的實例,但我不知道該怎麼做。
請幫助我,任何人。我想設置用戶組,例如,與UID 1
非常感謝您!但現在我看到另一個錯誤! ()必須是TYPO3 \ CMS \ Extbase \ Persistence \ ObjectStorage的實例,In2code \ Femanager \ Domain \ Model \ UserGroup,在第70行調用/home/abenteuer/public_html/typo3conf/ext/feusersplus/Classes/Controller/NewController.php並在/ home/abenteuer/public_html/typo3/sysext/extbase/Classes/Domain/Model/FrontendUser.php line 192 – Mikael
我也試過addUsergroup和我得到錯誤: PHP致命錯誤:調用成員函數attach()在非對象在/ home/abenteuer/public_html/typo3/sysext/extbase /類/域/模型/ FrontendUser.php – Mikael
@Mikael如果你想使用'setUsergroup()',你需要自己準備一個'ObjectStorage'實例。由於'usergroup'屬性的'ObjectStorage'是在'FrontendUser'構造函數中創建的,因此'addUsergroup'錯誤不應該發生。 –