Taxonomy view representative node contextual filter leads to incorrect results
First off do NOT put PHP code in the fixed value. This gets stored in the db which is a bad idea. Instead use taxonomy term ID from URL for the default value.

If that does not work as is use a hook. I would probably use hook_views_pre_view in this case. You can use the same code you have in your example to change your $args or $view-&gt;args can't remember which off the top of my head.