TYPO3CMS-Reference-CoreApi
TYPO3CMS-Reference-CoreApi copied to clipboard
Add example for removing something from the User settings
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Configuration/UserSettingsConfiguration/Index.html
Assume, you have different authentication mechanism (e.g. SSO) and want to remove changing password in User Settings (or remove entire "Account security" tab.
On the page "Extending the user settings" there is an example for adding something with the convenience function addFieldsToUserSettings.
I am not sure if there is an equivalent function for removing settings from the user settings.
You could (for example) do something like this but seems like a hack:
ext_tables.php
// remove entire
$GLOBALS['TYPO3_USER_SETTINGS']['showitem'] = str_replace(
'--div--;LLL:EXT:setup/Resources/Private/Language/locallang.xlf:accountSecurity,passwordCurrent,password,password2,mfaProviders,',
'', $GLOBALS['TYPO3_USER_SETTINGS']['showitem']);
// or better per regex:
$GLOBALS['TYPO3_USER_SETTINGS']['showitem'] = preg_replace(
'#--div--;LLL:EXT:setup\/Resources\/Private\/Language\/locallang.xlf:accountSecurity((?!--div--;).)*#',
'', $GLOBALS['TYPO3_USER_SETTINGS']['showitem']);
Should ideally be an API function in TYPO3 or at least have an example in the documentation?
Hmm, this is indeed very hacky. I would avoid documenting it as it may break in major TYPO3 upgrades (think of renaming one of the provided fields or adding one in between or just a space after the comma added).
When we agree to document something like this, this should be a more generic approach. I used it in my projects, for example, to change the existing pages TCA for custom doktypes. And there should be a BIG disclaimer above it, something like: "Use at own risk, this may break anytime. You should know what you do!"
We need a proper API for that, perhaps when the TCA is migrated internally to proper classes: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75486 (which is currently only for reading, not writing).
No action for over a year.