I have a custom profile plugin to extend user profile data. I want to add a switch to hide all BUT the core group of fields when the user checks and edits their profile. In my plugin (profileabc.php) file, within the function I have the following:
public function onContentPrepareForm(Form $form, $data)
{
// Check we are manipulating a valid form.
$name = $form->getName();
$limit_pw = $this->params->get('limit_pw', 0);
if ($limit_pw)
{
$fsets = $form->getFieldsets();
foreach ($fsets as $fgroup)
{
if ($fgroup !== 'core')
{
$form->removeGroup($fgroup);
}
}
// do nothing regarding the custom profile data
return true;
} ....
This works brilliantly except, the custom fields group/s remain exposed and accessible. Any guidance appreciated. Cheers.