Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for removing something from the User settings #1999

Open
sypets opened this issue Jul 26, 2022 · 1 comment
Open

Add example for removing something from the User settings #1999

sypets opened this issue Jul 26, 2022 · 1 comment

Comments

@sypets
Copy link
Contributor

sypets commented Jul 26, 2022

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?

@brotkrueml
Copy link
Contributor

brotkrueml commented Jan 29, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants