I think this line:
Code:
$value = trim($value, substr(fetch_censored_text($value), 0, $profilefield['maxlength']));
Should be:
Code:
$value = trim(substr($value, 0, $profilefield['maxlength']));
I think what you have works because trim() only looks at the first argument, but the value doesn't go through substr() to make sure it's no longer than the max length.
ETA: ...but it's not a big deal, I'm pretty sure it will be OK the way it is.