I'm trying to extend the RainLab User plugin, and need to filter a field in the backend form.
If I edit the User model directly I get it to function, but I'm trying to do from my own Plugin registration file with "addDynamicMethod" without luck. Code on the User model file:
public function filterFields($fields, $context = null)
{
if (property_exists($fields, 'usertype')) {
$userType = $fields->usertype->value;
if($userType == $this->AGENT || $userType == null) {
$fields->agent->hidden = true;
}
}
}